Skip to content

Commit 485eb95

Browse files
committed
Merge branch 'release/1.2.8'
2 parents ca63b1b + c3aff0b commit 485eb95

24 files changed

+699
-169
lines changed

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
**Donate Link:** http://tareq.co/donate/
44
**Tags:** WooCommerce POS, point of sale, free pos, pos plugin, woocommerce point of sale
55
**Requires at least:** 5.4
6-
**Tested up to:** 6.4.2
6+
**Tested up to:** 6.5.3
77
**WC requires at least:** 5.0.0
8-
**WC tested up to:** 8.4.0
9-
**Requires PHP:** 7.2
10-
**Stable tag:** 1.2.7
8+
**WC tested up to:** 8.9.2
9+
**Requires PHP:** 7.4
10+
**Stable tag:** 1.2.8
1111
**License:** GPLv2 or later
1212
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1313

@@ -60,6 +60,11 @@ No FAQ
6060

6161
## Changelog ##
6262

63+
### v1.2.8 -> 05 June, 2024 ###
64+
- **Feature:** WooCommerce Coupon API integration for cart discount
65+
- **Enhancement:** Added support for WooCommerce customised order numbers by third-party plugins
66+
- **Fix:** Blurry numbers on print receipt
67+
6368
### v1.2.7 -> 27 December, 2023 ###
6469
- **Enhancement:** Tax calculation implementation based on discounts and fees instead of base price of products
6570

assets/css/frontend.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/frontend.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/admin.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/admin.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/frontend.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/frontend.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/frontend/components/Home.vue

+113-5
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,45 @@
247247
<td class="label">
248248
{{ __( 'Subtotal', 'wepos' ) }}
249249
<span class="name" v-if="settings.woo_tax.wc_tax_display_cart == 'incl' && $store.getters['Cart/getTotalLineTax'] > 0">
250-
{{ __( 'Includes Tax', 'wepos' ) }} {{ formatPrice( $store.getters['Cart/getTotalLineTax'] ) }}
250+
{{ __( 'Including Tax', 'wepos' ) }}
251251
</span>
252252
</td>
253253
<td class="price">{{ formatPrice( $store.getters['Cart/getSubtotal'] ) }}</td>
254254
<td class="action"></td>
255255
</tr>
256+
257+
<template v-if="cartdata.coupon_lines.length > 0">
258+
<tr class="cart-meta-data" v-for="(fee,key) in cartdata.coupon_lines">
259+
<template v-if="fee.type=='discount'">
260+
<td class="label">{{ __( 'Discount', 'wepos' ) }} <span class="name">{{ getDiscountAmount( fee ) }}</span></td>
261+
<td class="price">&minus;{{ formatPrice( Math.abs( fee.total ) ) }}</td>
262+
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
263+
</template>
264+
<template v-else>
265+
<template v-if="cartdata.coupon_lines[key].isEdit">
266+
<td class="label" colspan="2">
267+
<input type="text" class="fee-name" v-model="feeData.name" :placeholder="__( 'Fee Name', 'wepos' )" ref="fee_name">
268+
<input type="number" class="fee-amount" min="0" step="any" v-model="feeData.value" :placeholder="__( 'Total', 'wepos' )" ref="fee_total">
269+
<template v-if="settings.wepos_general.enable_fee_tax == 'yes'">
270+
<label for="fee-tax-status"><input type="checkbox" id="fee-tax-status" class="fee-tax-status" v-model="feeData.tax_status" :true-value="'taxable'" :false-value="'none'"> {{ __( 'Taxable', 'wepos' ) }}</label>
271+
<select class="fee-tax-class" v-model="feeData.tax_class" v-if="feeData.tax_status=='taxable'">
272+
<option v-for="feeTax in availableTax" :value="feeTax.class == 'standard' ? '' : feeTax.class">{{ unSanitizeString( feeTax.class ) }} - {{ feeTax.percentage_rate }}</option>
273+
</select>
274+
</template>
275+
<button :disabled="feeData.name == ''" @click.prevent="saveFee(key)">{{ __( 'Apply', 'wepos' ) }}</button>
276+
<button class="cancel" @click.prevent="cancelEditFee(key)">{{ __( 'Cancel', 'wepos' ) }}</button>
277+
</td>
278+
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
279+
</template>
280+
<template v-else>
281+
<td class="label" @dblclick.prevent="editFeeData(key)">{{ __( 'Fee', 'wepos' ) }} <span class="name">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></td>
282+
<td class="price">{{ formatPrice( Math.abs( fee.total ) ) }}</td>
283+
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
284+
</template>
285+
</template>
286+
</tr>
287+
</template>
288+
256289
<template v-if="cartdata.fee_lines.length > 0">
257290
<tr class="cart-meta-data" v-for="(fee,key) in cartdata.fee_lines">
258291
<template v-if="fee.type=='discount'">
@@ -285,7 +318,7 @@
285318
</tr>
286319
</template>
287320
<tr class="tax" v-if="$store.getters['Cart/getTotalTax']">
288-
<td class="label">{{ __( 'Tax', 'wepos' ) }}</td>
321+
<td class="label">{{ settings.woo_tax.wc_tax_display_cart === 'incl' ? __( 'Fee Tax', 'wepos' ) : __( 'Tax', 'wepos' ) }}</td>
289322
<td class="price">{{ formatPrice( $store.getters['Cart/getTotalTax'] ) }}</td>
290323
<td class="action"></td>
291324
</tr>
@@ -443,11 +476,25 @@
443476
<span class="wepos-left">
444477
{{ __( 'Subtotal', 'wepos' ) }}
445478
<span class="metadata" v-if="settings.woo_tax.wc_tax_display_cart == 'incl'">
446-
{{ __( 'Includes Tax', 'wepos' ) }} {{ formatPrice( $store.getters['Cart/getTotalLineTax'] ) }}
479+
{{ __( 'Including Tax', 'wepos' ) }}
447480
</span>
448481
</span>
449482
<span class="wepos-right">{{ formatPrice( $store.getters['Cart/getSubtotal'] ) }}</span>
450483
</li>
484+
485+
<template v-if="cartdata.coupon_lines.length > 0">
486+
<li class="wepos-clearfix" v-for="(fee,key) in cartdata.coupon_lines">
487+
<template v-if="fee.type=='discount'">
488+
<span class="wepos-left">{{ __( 'Discount', 'wepos' ) }} <span class="metadata">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></span>
489+
<span class="wepos-right">-{{ formatPrice( Math.abs( fee.total ) ) }}</span>
490+
</template>
491+
<template v-else>
492+
<span class="wepos-left">{{ __( 'Fee', 'wepos' ) }} <span class="metadata">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></span>
493+
<span class="wepos-right">{{ formatPrice( fee.total ) }}</span>
494+
</template>
495+
</li>
496+
</template>
497+
451498
<template v-if="cartdata.fee_lines.length > 0">
452499
<li class="wepos-clearfix" v-for="(fee,key) in cartdata.fee_lines">
453500
<template v-if="fee.type=='discount'">
@@ -619,6 +666,7 @@ export default {
619666
availableGatewayContent: wepos.hooks.applyFilters( 'wepos_avaialable_gateway_content', [] ),
620667
afterMainContents: wepos.hooks.applyFilters( 'wepos_after_main_content', [] ),
621668
beforCartPanels: wepos.hooks.applyFilters( 'wepos_before_cart_panel', [] ),
669+
couponData: {},
622670
}
623671
},
624672
computed: {
@@ -792,6 +840,7 @@ export default {
792840
shipping: this.orderdata.shipping,
793841
line_items: this.cartdata.line_items,
794842
fee_lines: this.cartdata.fee_lines,
843+
coupon_lines: this.cartdata.coupon_lines,
795844
customer_id: this.orderdata.customer_id,
796845
customer_note: this.orderdata.customer_note,
797846
payment_method: this.orderdata.payment_method,
@@ -817,6 +866,19 @@ export default {
817866
818867
wepos.api.post( wepos.rest.root + wepos.rest.wcversion + '/orders', orderdata )
819868
.done( response => {
869+
const orderResult = response;
870+
const totalTaxes = {};
871+
872+
// Looping through line items and get total tax for each items.
873+
orderResult.line_items.forEach( item => {
874+
totalTaxes[item.product_id] = item.total_tax
875+
} );
876+
877+
// Preserve total tax amount for each of the line items to the cart.
878+
this.cartdata.line_items.forEach( item => {
879+
item.total_tax = totalTaxes[ item.product_id ];
880+
} );
881+
820882
wepos.api.post( wepos.rest.root + wepos.rest.posversion + '/payment/process', response )
821883
.done( data => {
822884
if ( data.result == 'success' ) {
@@ -830,14 +892,15 @@ export default {
830892
this.printdata = wepos.hooks.applyFilters( 'wepos_after_payment_print_data', {
831893
line_items: this.cartdata.line_items,
832894
fee_lines: this.cartdata.fee_lines,
895+
coupon_lines: this.cartdata.coupon_lines,
833896
subtotal: this.$store.getters['Cart/getSubtotal'],
834897
taxtotal: this.$store.getters['Cart/getTotalTax'],
835898
ordertotal: this.$store.getters['Cart/getTotal'],
836899
gateway: {
837900
id: response.payment_method,
838901
title: response.payment_method_title
839902
},
840-
order_id: response.id,
903+
order_id: response.number,
841904
order_date: response.date_created,
842905
cashamount: this.cashAmount.toString(),
843906
changeamount: this.changeAmount.toString()
@@ -881,7 +944,49 @@ export default {
881944
return ( product.images.length > 0 ) ? product.images[0].name : product.name;
882945
},
883946
setDiscount( value, type ) {
884-
this.$store.dispatch( 'Cart/addDiscountAction', { title: this.__( 'Discount', 'wepos' ), value: value, type: type } );
947+
this.createCoupon( value, type, this.dispatchCoupon );
948+
},
949+
createCoupon( amount, discount_type, callback ) {
950+
let self = this;
951+
let id = Date.now();
952+
let code = discount_type + id + amount;
953+
954+
self.couponData = {};
955+
956+
const discountdata = {
957+
code: code,
958+
amount: amount,
959+
usage_limit: 1,
960+
meta_data : [
961+
{
962+
key: 'wepos_cart_discount',
963+
value: 'yes',
964+
},
965+
],
966+
}
967+
968+
if ( 'percent' === discount_type ) {
969+
discountdata.discount_type = discount_type;
970+
}
971+
972+
wepos.api.post( wepos.rest.root + wepos.rest.posversion + '/coupons', discountdata )
973+
.done( data => {
974+
self.couponData = data;
975+
976+
callback( data, discount_type );
977+
} ).fail( data => {
978+
alert( data.responseJSON.message );
979+
} );
980+
},
981+
dispatchCoupon( couponData, type ) {
982+
this.$store.dispatch(
983+
'Cart/addDiscountAction',
984+
{
985+
title: this.__( 'Discount', 'wepos' ),
986+
value: couponData,
987+
type
988+
}
989+
);
885990
},
886991
saveFee( key ) {
887992
this.$store.dispatch( 'Cart/saveFeeValueAction', { key: key, feeData: this.feeData } );
@@ -901,6 +1006,9 @@ export default {
9011006
setFee( value, type ) {
9021007
this.$store.dispatch( 'Cart/addFeeAction', { title: this.__( 'Fee', 'wepos' ), value: value, type: type } );
9031008
},
1009+
removeCouponLine( key ) {
1010+
this.$store.dispatch( 'Cart/removeCouponLineItemsAction', key );
1011+
},
9041012
removeFeeLine( key ) {
9051013
this.$store.dispatch( 'Cart/removeFeeLineItemsAction', key );
9061014
},

0 commit comments

Comments
 (0)