Skip to content

Commit

Permalink
fix: vendor wise commission decimal issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbir1991 committed Jul 20, 2020
1 parent 84b0aca commit f163ec0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
18 changes: 13 additions & 5 deletions assets/js/vue-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3176,8 +3176,9 @@ var render = function() {
expression: "vendorInfo.admin_commission"
}
],
staticClass: "dokan-form-input percent_fee",
attrs: { type: "number" },
staticClass:
"wc_input_decimal dokan-form-input percent_fee",
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_commission
},
Expand Down Expand Up @@ -3210,8 +3211,9 @@ var render = function() {
"vendorInfo.admin_additional_fee"
}
],
staticClass: "dokan-form-input fixed_fee",
attrs: { type: "number" },
staticClass:
"wc_input_price dokan-form-input fixed_fee",
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_additional_fee
},
Expand Down Expand Up @@ -3249,7 +3251,13 @@ var render = function() {
}
],
staticClass: "dokan-form-input",
attrs: { type: "number" },
class: {
wc_input_price:
_vm.selectedCommissionType.name == "flat",
wc_input_decimal:
_vm.selectedCommissionType.name != "flat"
},
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_commission
},
Expand Down
18 changes: 13 additions & 5 deletions assets/js/vue-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3171,8 +3171,9 @@ var render = function() {
expression: "vendorInfo.admin_commission"
}
],
staticClass: "dokan-form-input percent_fee",
attrs: { type: "number" },
staticClass:
"wc_input_decimal dokan-form-input percent_fee",
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_commission
},
Expand Down Expand Up @@ -3205,8 +3206,9 @@ var render = function() {
"vendorInfo.admin_additional_fee"
}
],
staticClass: "dokan-form-input fixed_fee",
attrs: { type: "number" },
staticClass:
"wc_input_price dokan-form-input fixed_fee",
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_additional_fee
},
Expand Down Expand Up @@ -3244,7 +3246,13 @@ var render = function() {
}
],
staticClass: "dokan-form-input",
attrs: { type: "number" },
class: {
wc_input_price:
_vm.selectedCommissionType.name == "flat",
wc_input_decimal:
_vm.selectedCommissionType.name != "flat"
},
attrs: { type: "text" },
domProps: {
value: _vm.vendorInfo.admin_commission
},
Expand Down
8 changes: 4 additions & 4 deletions includes/Vendor/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ public function update( $vendor_id, $data = [] ) {
$vendor->update_meta( 'dokan_publishing', 'no' );
}

if ( isset( $data['admin_commission'] ) && ( is_numeric( $data['admin_commission'] ) || '' === $data['admin_commission'] ) ) {
$vendor->update_meta( 'dokan_admin_percentage', $data['admin_commission'] );
}

if ( ! empty( $data['admin_commission_type'] ) ) {
$vendor->update_meta( 'dokan_admin_percentage_type', $data['admin_commission_type'] );
}

if ( isset( $data['admin_commission'] ) && ( is_numeric( $data['admin_commission'] ) || '' === $data['admin_commission'] ) ) {
$vendor->update_meta( 'dokan_admin_percentage', wc_format_decimal( $data['admin_commission'] ) );
}
}

// update vendor store data
Expand Down
8 changes: 4 additions & 4 deletions src/admin/pages/VendorPaymentFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
<div class="column combine-commission" v-if="'combine' === selectedCommissionType.name">
<label>{{ __( 'Admin Commission', 'dokan-lite' ) }}</label>
<div class="combine-commission-field">
<input type="number" class="dokan-form-input percent_fee" v-model="vendorInfo.admin_commission">
<input type="text" class="wc_input_decimal dokan-form-input percent_fee" v-model="vendorInfo.admin_commission">
{{ '% &nbsp;&nbsp; +' }}
<input type="number" class="dokan-form-input fixed_fee" v-model="vendorInfo.admin_additional_fee">
<input type="text" class="wc_input_price dokan-form-input fixed_fee" v-model="vendorInfo.admin_additional_fee">
</div>
</div>

<div class="column" v-else>
<label>{{ __( 'Admin Commission', 'dokan-lite' ) }}</label>
<input type="number" class="dokan-form-input" v-model="vendorInfo.admin_commission">
<input type="text" class="dokan-form-input" :class="{ 'wc_input_price': selectedCommissionType.name == 'flat', 'wc_input_decimal': selectedCommissionType.name != 'flat' }" v-model="vendorInfo.admin_commission">
</div>
</template>

Expand Down Expand Up @@ -259,4 +259,4 @@ export default {
}
}
}
</style>
</style>

0 comments on commit f163ec0

Please sign in to comment.