Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:weDevsOfficial/dokan into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbir1991 committed Oct 26, 2018
2 parents 78bc882 + 16b2909 commit 35a757c
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 23 deletions.
6 changes: 3 additions & 3 deletions assets/css/setup.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@
}
.wc-setup .wc-setup-actions .button-primary {
color: #fff;
background: #f2624d !important;
border-color: #f2624d !important;
background: #f2624d;
border-color: #f2624d;
text-shadow: 0 -1px 1px #ef381d, 1px 0 1px #ef381d, 0 1px 1px #ef381d, -1px 0 1px #ef381d;
}
.wc-setup .wc-setup-actions .button-primary:hover,
.wc-setup .wc-setup-actions .button-primary:active,
.wc-setup .wc-setup-actions .button-primary:focus {
background-color: #ef381d !important;
background-color: #ef381d;
}
.wc-setup .wc-setup-content a {
color: #f2624d;
Expand Down
4 changes: 2 additions & 2 deletions classes/seller-setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public function dokan_setup_introduction() {
<p><?php _e( 'Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than two minutes.</strong>', 'dokan-lite' ); ?></p>
<p><?php _e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the Store!', 'dokan-lite' ); ?></p>
<p class="wc-setup-actions step">
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next lets-go-btn"><?php _e( 'Let\'s Go!', 'dokan-lite' ); ?></a>
<a href="<?php echo esc_url( $dashboard_url ); ?>" class="button button-large not-right-now-btn"><?php _e( 'Not right now', 'dokan-lite' ); ?></a>
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next lets-go-btn dokan-btn-theme"><?php _e( 'Let\'s Go!', 'dokan-lite' ); ?></a>
<a href="<?php echo esc_url( $dashboard_url ); ?>" class="button button-large not-right-now-btn dokan-btn-theme"><?php _e( 'Not right now', 'dokan-lite' ); ?></a>
</p>
<?php
do_action( 'dokan_seller_wizard_introduction', $this );
Expand Down
2 changes: 2 additions & 0 deletions classes/template-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ public static function load_download_virtual_template( $post, $post_id ) {
public static function load_inventory_template( $post, $post_id ) {
$_sold_individually = get_post_meta( $post_id, '_sold_individually', true );
$_stock = get_post_meta( $post_id, '_stock', true );
$_low_stock_amount = get_post_meta( $post_id, '_low_stock_amount', true );

dokan_get_template_part( 'products/inventory', '', array(
'post_id' => $post_id,
'post' => $post,
'_sold_individually' => $_sold_individually,
'_stock' => $_stock,
'_low_stock_amount' => $_low_stock_amount,
'class' => ''
) );
}
Expand Down
3 changes: 2 additions & 1 deletion includes/api/class-api-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function get_items( $request ) {
$result = $query->query( $query_args );

$data = array();
$data_objects = array();
$objects = array_map( array( $this, 'get_object' ), $result );

foreach ( $objects as $object ) {
Expand Down Expand Up @@ -418,4 +419,4 @@ public function format_collection_response( $response, $request, $total_items )
return $response;
}

}
}
16 changes: 16 additions & 0 deletions includes/api/class-product-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ protected function prepare_data_for_response( $product, $request ) {
'tax_class' => $product->get_tax_class( $context ),
'manage_stock' => $product->managing_stock(),
'stock_quantity' => $product->get_stock_quantity( $context ),
'low_stock_amount' => version_compare( WC_VERSION, '3.4.7', '>' ) ? $product->get_low_stock_amount( $context ) : '',
'in_stock' => $product->is_in_stock(),
'backorders' => $product->get_backorders( $context ),
'backorders_allowed' => $product->backorders_allowed(),
Expand Down Expand Up @@ -978,11 +979,21 @@ protected function prepare_object_for_database( $request, $creating = false ) {
$product->set_backorders( 'no' );
$product->set_stock_quantity( '' );
$product->set_stock_status( $stock_status );

if ( version_compare( WC_VERSION, '3.4.7', '>' ) ) {
$product->set_low_stock_amount( '' );
}

} elseif ( $product->is_type( 'external' ) ) {
$product->set_manage_stock( 'no' );
$product->set_backorders( 'no' );
$product->set_stock_quantity( '' );
$product->set_stock_status( 'instock' );

if ( version_compare( WC_VERSION, '3.4.7', '>' ) ) {
$product->set_low_stock_amount( '' );
}

} elseif ( $product->get_manage_stock() ) {
// Stock status is always determined by children so sync later.
if ( ! $product->is_type( 'variable' ) ) {
Expand All @@ -992,11 +1003,16 @@ protected function prepare_object_for_database( $request, $creating = false ) {
// Stock quantity.
if ( isset( $request['stock_quantity'] ) ) {
$product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) );

} elseif ( isset( $request['inventory_delta'] ) ) {
$stock_quantity = wc_stock_amount( $product->get_stock_quantity() );
$stock_quantity += wc_stock_amount( $request['inventory_delta'] );
$product->set_stock_quantity( wc_stock_amount( $stock_quantity ) );
}

if ( version_compare( WC_VERSION, '3.4.7', '>' ) && isset( $request['low_stock_amount'] ) ) {
$product->set_low_stock_amount( wc_stock_amount( $request['low_stock_amount'] ) );
}
} else {
// Don't manage stock.
$product->set_manage_stock( 'no' );
Expand Down
21 changes: 16 additions & 5 deletions includes/wc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,13 @@ function dokan_process_product_meta( $post_id ) {
}

// Stock Data
$manage_stock = ! empty( $_POST['_manage_stock'] ) && 'grouped' !== $product_type ? 'yes' : 'no';
$backorders = ! empty( $_POST['_backorders'] ) && 'yes' === $manage_stock ? wc_clean( $_POST['_backorders'] ) : 'no';
$stock_status = ! empty( $_POST['_stock_status'] ) ? wc_clean( $_POST['_stock_status'] ) : 'instock';
$stock_amount = 'yes' === $manage_stock ? wc_stock_amount( $_POST['_stock'] ) : '';
$manage_stock = ! empty( $_POST['_manage_stock'] ) && 'grouped' !== $product_type ? 'yes' : 'no';
$backorders = ! empty( $_POST['_backorders'] ) && 'yes' === $manage_stock ? wc_clean( $_POST['_backorders'] ) : 'no';
$stock_status = ! empty( $_POST['_stock_status'] ) ? wc_clean( $_POST['_stock_status'] ) : 'instock';
$stock_amount = isset( $_POST['_stock'] ) ? $_POST['_stock'] : '';
$stock_amount = 'yes' === $manage_stock ? wc_stock_amount( wp_unslash( $stock_amount ) ) : '';
$_low_stock_amount = isset( $_POST['_low_stock_amount'] ) ? $_POST['_low_stock_amount'] : '';
$_low_stock_amount = 'yes' === $manage_stock ? wc_stock_amount( wp_unslash( $_low_stock_amount ) ) : '';

// Stock Data
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
Expand Down Expand Up @@ -311,9 +314,17 @@ function dokan_process_product_meta( $post_id ) {
}

if ( ! empty( $_POST['_manage_stock'] ) ) {
wc_update_product_stock( $post_id, wc_stock_amount( $_POST['_stock'] ) );

if ( 'variable' === $product_type ) {
update_post_meta( $post_id, '_stock', $stock_amount );
} else {
wc_update_product_stock( $post_id, $stock_amount );
}

update_post_meta( $post_id, '_low_stock_amount', wc_stock_amount( $_POST['_low_stock_amount'] ) );
} else {
update_post_meta( $post_id, '_stock', '' );
update_post_meta( $post_id, '_low_stock_amount', '' );
}

} else {
Expand Down
15 changes: 15 additions & 0 deletions src/admin/components/Currency.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div v-html="formattedPrice( amount )"></div>
</template>

<script>
export default {
props : ['amount'],
methods: {
formattedPrice(value) {
return accounting.formatMoney( value, dokan.currency );
}
}
};
</script>
16 changes: 11 additions & 5 deletions src/admin/pages/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<li class="sale">
<div class="dashicons dashicons-chart-bar"></div>
<a href="#">
<strong>{{ overview.orders.this_month | currency }}</strong>
<strong>
<currency :amount="overview.orders.this_month"></currency>
</strong>
<div class="details">
{{ __( 'net sales this month', 'dokan-lite' ) }} <span :class="overview.orders.class">{{ overview.orders.parcent }}</span>
</div>
Expand All @@ -19,7 +21,9 @@
<li class="commission">
<div class="dashicons dashicons-chart-pie"></div>
<a href="#">
<strong>{{ overview.earning.this_month | currency }}</strong>
<strong>
<currency :amount="overview.earning.this_month"></currency>
</strong>
<div class="details">
{{ __( 'commission earned', 'dokan-lite' ) }} <span :class="overview.earning.class">{{ overview.earning.parcent }}</span>
</div>
Expand Down Expand Up @@ -109,8 +113,9 @@
</template>

<script>
let Postbox = dokan_get_lib('Postbox');
let Loading = dokan_get_lib('Loading');
let Postbox = dokan_get_lib('Postbox');
let Loading = dokan_get_lib('Loading');
let Currency = dokan_get_lib('Currency');
import Chart from "admin/components/Chart.vue"
Expand All @@ -121,7 +126,8 @@ export default {
components: {
Postbox,
Loading,
Chart
Chart,
Currency
},
data () {
Expand Down
6 changes: 4 additions & 2 deletions src/admin/pages/Withdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</template>

<template slot="amount" slot-scope="data">
{{ data.row.amount | currency }}
<currency :amount="data.row.amount"></currency>
</template>

<template slot="status" slot-scope="data">
Expand Down Expand Up @@ -85,7 +85,8 @@

<script>
let ListTable = dokan_get_lib('ListTable');
let Modal = dokan_get_lib('Modal');
let Modal = dokan_get_lib('Modal');
let Currency = dokan_get_lib('Currency');
export default {
Expand All @@ -94,6 +95,7 @@ export default {
components: {
ListTable,
Modal,
Currency
},
data () {
Expand Down
6 changes: 2 additions & 4 deletions src/utils/Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Chart from "admin/components/Chart.vue"
import Modal from "admin/components/Modal.vue"
import Switches from "admin/components/Switches.vue"
import TextEditor from "admin/components/TextEditor.vue"
import Currency from "admin/components/Currency.vue"

import "vue-multiselect/dist/vue-multiselect.min.css"

Expand All @@ -37,10 +38,6 @@ Vue.component('multiselect', Multiselect)

Vue.mixin( Mixin );

Vue.filter('currency', function (value) {
return accounting.formatMoney(value, dokan.currency);
})

Vue.filter('capitalize', function (value) {
if (!value) return ''
value = value.toString()
Expand Down Expand Up @@ -72,6 +69,7 @@ window.dokan.libs['Router'] = Router;
window.dokan.libs['moment'] = Moment;

window.dokan.libs['ListTable'] = ListTable;
window.dokan.libs['Currency'] = Currency;
window.dokan.libs['Postbox'] = Postbox;
window.dokan.libs['Loading'] = Loading;
window.dokan.libs['ChartJS'] = ChartJS;
Expand Down
9 changes: 8 additions & 1 deletion templates/products/inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@
<div class="show_if_stock dokan-stock-management-wrapper dokan-form-group dokan-clearfix">

<div class="content-half-part hide_if_variation">
<label for="_stock" class="form-label"><?php _e( 'Quantity', 'dokan-lite' ); ?></label>
<label for="_stock" class="form-label"><?php _e( 'Stock quantity', 'dokan-lite' ); ?></label>
<input type="number" class="dokan-form-control" name="_stock" placeholder="<?php __( '1', 'dokan-lite' ); ?>" value="<?php echo wc_stock_amount( $_stock ); ?>" min="0" step="1">
</div>

<?php if ( version_compare( WC_VERSION, '3.4.7', '>' ) ) : ?>
<div class="content-half-part hide_if_variation">
<label for="_low_stock_amount" class="form-label"><?php _e( 'Low stock threshold', 'dokan-lite' ); ?></label>
<input type="number" class="dokan-form-control" name="_low_stock_amount" placeholder="<?php __( '1', 'dokan-lite' ); ?>" value="<?php echo wc_stock_amount( $_low_stock_amount ); ?>" min="0" step="1">
</div>
<?php endif; ?>

<div class="content-half-part hide_if_variation last-child">
<label for="_backorders" class="form-label"><?php _e( 'Allow Backorders', 'dokan-lite' ); ?></label>

Expand Down

0 comments on commit 35a757c

Please sign in to comment.