Skip to content

Commit

Permalink
Merge branch 'release/1.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
devAsadNur committed Jun 5, 2024
2 parents ca63b1b + c3aff0b commit 485eb95
Show file tree
Hide file tree
Showing 24 changed files with 699 additions and 169 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
**Donate Link:** http://tareq.co/donate/
**Tags:** WooCommerce POS, point of sale, free pos, pos plugin, woocommerce point of sale
**Requires at least:** 5.4
**Tested up to:** 6.4.2
**Tested up to:** 6.5.3
**WC requires at least:** 5.0.0
**WC tested up to:** 8.4.0
**Requires PHP:** 7.2
**Stable tag:** 1.2.7
**WC tested up to:** 8.9.2
**Requires PHP:** 7.4
**Stable tag:** 1.2.8
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -60,6 +60,11 @@ No FAQ

## Changelog ##

### v1.2.8 -> 05 June, 2024 ###
- **Feature:** WooCommerce Coupon API integration for cart discount
- **Enhancement:** Added support for WooCommerce customised order numbers by third-party plugins
- **Fix:** Blurry numbers on print receipt

### v1.2.7 -> 27 December, 2023 ###
- **Enhancement:** Tax calculation implementation based on discounts and fees instead of base price of products

Expand Down
2 changes: 1 addition & 1 deletion assets/css/frontend.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/frontend.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/admin.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions assets/js/frontend.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/frontend.min.js

Large diffs are not rendered by default.

118 changes: 113 additions & 5 deletions assets/src/frontend/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,45 @@
<td class="label">
{{ __( 'Subtotal', 'wepos' ) }}
<span class="name" v-if="settings.woo_tax.wc_tax_display_cart == 'incl' && $store.getters['Cart/getTotalLineTax'] > 0">
{{ __( 'Includes Tax', 'wepos' ) }} {{ formatPrice( $store.getters['Cart/getTotalLineTax'] ) }}
{{ __( 'Including Tax', 'wepos' ) }}
</span>
</td>
<td class="price">{{ formatPrice( $store.getters['Cart/getSubtotal'] ) }}</td>
<td class="action"></td>
</tr>

<template v-if="cartdata.coupon_lines.length > 0">
<tr class="cart-meta-data" v-for="(fee,key) in cartdata.coupon_lines">
<template v-if="fee.type=='discount'">
<td class="label">{{ __( 'Discount', 'wepos' ) }} <span class="name">{{ getDiscountAmount( fee ) }}</span></td>
<td class="price">&minus;{{ formatPrice( Math.abs( fee.total ) ) }}</td>
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
</template>
<template v-else>
<template v-if="cartdata.coupon_lines[key].isEdit">
<td class="label" colspan="2">
<input type="text" class="fee-name" v-model="feeData.name" :placeholder="__( 'Fee Name', 'wepos' )" ref="fee_name">
<input type="number" class="fee-amount" min="0" step="any" v-model="feeData.value" :placeholder="__( 'Total', 'wepos' )" ref="fee_total">
<template v-if="settings.wepos_general.enable_fee_tax == 'yes'">
<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>
<select class="fee-tax-class" v-model="feeData.tax_class" v-if="feeData.tax_status=='taxable'">
<option v-for="feeTax in availableTax" :value="feeTax.class == 'standard' ? '' : feeTax.class">{{ unSanitizeString( feeTax.class ) }} - {{ feeTax.percentage_rate }}</option>
</select>
</template>
<button :disabled="feeData.name == ''" @click.prevent="saveFee(key)">{{ __( 'Apply', 'wepos' ) }}</button>
<button class="cancel" @click.prevent="cancelEditFee(key)">{{ __( 'Cancel', 'wepos' ) }}</button>
</td>
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
</template>
<template v-else>
<td class="label" @dblclick.prevent="editFeeData(key)">{{ __( 'Fee', 'wepos' ) }} <span class="name">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></td>
<td class="price">{{ formatPrice( Math.abs( fee.total ) ) }}</td>
<td class="action"><span class="flaticon-cancel-music" @click="removeCouponLine(key)"></span></td>
</template>
</template>
</tr>
</template>

<template v-if="cartdata.fee_lines.length > 0">
<tr class="cart-meta-data" v-for="(fee,key) in cartdata.fee_lines">
<template v-if="fee.type=='discount'">
Expand Down Expand Up @@ -285,7 +318,7 @@
</tr>
</template>
<tr class="tax" v-if="$store.getters['Cart/getTotalTax']">
<td class="label">{{ __( 'Tax', 'wepos' ) }}</td>
<td class="label">{{ settings.woo_tax.wc_tax_display_cart === 'incl' ? __( 'Fee Tax', 'wepos' ) : __( 'Tax', 'wepos' ) }}</td>
<td class="price">{{ formatPrice( $store.getters['Cart/getTotalTax'] ) }}</td>
<td class="action"></td>
</tr>
Expand Down Expand Up @@ -443,11 +476,25 @@
<span class="wepos-left">
{{ __( 'Subtotal', 'wepos' ) }}
<span class="metadata" v-if="settings.woo_tax.wc_tax_display_cart == 'incl'">
{{ __( 'Includes Tax', 'wepos' ) }} {{ formatPrice( $store.getters['Cart/getTotalLineTax'] ) }}
{{ __( 'Including Tax', 'wepos' ) }}
</span>
</span>
<span class="wepos-right">{{ formatPrice( $store.getters['Cart/getSubtotal'] ) }}</span>
</li>

<template v-if="cartdata.coupon_lines.length > 0">
<li class="wepos-clearfix" v-for="(fee,key) in cartdata.coupon_lines">
<template v-if="fee.type=='discount'">
<span class="wepos-left">{{ __( 'Discount', 'wepos' ) }} <span class="metadata">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></span>
<span class="wepos-right">-{{ formatPrice( Math.abs( fee.total ) ) }}</span>
</template>
<template v-else>
<span class="wepos-left">{{ __( 'Fee', 'wepos' ) }} <span class="metadata">{{ fee.name }} {{ getDiscountAmount( fee ) }}</span></span>
<span class="wepos-right">{{ formatPrice( fee.total ) }}</span>
</template>
</li>
</template>

<template v-if="cartdata.fee_lines.length > 0">
<li class="wepos-clearfix" v-for="(fee,key) in cartdata.fee_lines">
<template v-if="fee.type=='discount'">
Expand Down Expand Up @@ -619,6 +666,7 @@ export default {
availableGatewayContent: wepos.hooks.applyFilters( 'wepos_avaialable_gateway_content', [] ),
afterMainContents: wepos.hooks.applyFilters( 'wepos_after_main_content', [] ),
beforCartPanels: wepos.hooks.applyFilters( 'wepos_before_cart_panel', [] ),
couponData: {},
}
},
computed: {
Expand Down Expand Up @@ -792,6 +840,7 @@ export default {
shipping: this.orderdata.shipping,
line_items: this.cartdata.line_items,
fee_lines: this.cartdata.fee_lines,
coupon_lines: this.cartdata.coupon_lines,
customer_id: this.orderdata.customer_id,
customer_note: this.orderdata.customer_note,
payment_method: this.orderdata.payment_method,
Expand All @@ -817,6 +866,19 @@ export default {
wepos.api.post( wepos.rest.root + wepos.rest.wcversion + '/orders', orderdata )
.done( response => {
const orderResult = response;
const totalTaxes = {};
// Looping through line items and get total tax for each items.
orderResult.line_items.forEach( item => {
totalTaxes[item.product_id] = item.total_tax
} );
// Preserve total tax amount for each of the line items to the cart.
this.cartdata.line_items.forEach( item => {
item.total_tax = totalTaxes[ item.product_id ];
} );
wepos.api.post( wepos.rest.root + wepos.rest.posversion + '/payment/process', response )
.done( data => {
if ( data.result == 'success' ) {
Expand All @@ -830,14 +892,15 @@ export default {
this.printdata = wepos.hooks.applyFilters( 'wepos_after_payment_print_data', {
line_items: this.cartdata.line_items,
fee_lines: this.cartdata.fee_lines,
coupon_lines: this.cartdata.coupon_lines,
subtotal: this.$store.getters['Cart/getSubtotal'],
taxtotal: this.$store.getters['Cart/getTotalTax'],
ordertotal: this.$store.getters['Cart/getTotal'],
gateway: {
id: response.payment_method,
title: response.payment_method_title
},
order_id: response.id,
order_id: response.number,
order_date: response.date_created,
cashamount: this.cashAmount.toString(),
changeamount: this.changeAmount.toString()
Expand Down Expand Up @@ -881,7 +944,49 @@ export default {
return ( product.images.length > 0 ) ? product.images[0].name : product.name;
},
setDiscount( value, type ) {
this.$store.dispatch( 'Cart/addDiscountAction', { title: this.__( 'Discount', 'wepos' ), value: value, type: type } );
this.createCoupon( value, type, this.dispatchCoupon );
},
createCoupon( amount, discount_type, callback ) {
let self = this;
let id = Date.now();
let code = discount_type + id + amount;
self.couponData = {};
const discountdata = {
code: code,
amount: amount,
usage_limit: 1,
meta_data : [
{
key: 'wepos_cart_discount',
value: 'yes',
},
],
}
if ( 'percent' === discount_type ) {
discountdata.discount_type = discount_type;
}
wepos.api.post( wepos.rest.root + wepos.rest.posversion + '/coupons', discountdata )
.done( data => {
self.couponData = data;
callback( data, discount_type );
} ).fail( data => {
alert( data.responseJSON.message );
} );
},
dispatchCoupon( couponData, type ) {
this.$store.dispatch(
'Cart/addDiscountAction',
{
title: this.__( 'Discount', 'wepos' ),
value: couponData,
type
}
);
},
saveFee( key ) {
this.$store.dispatch( 'Cart/saveFeeValueAction', { key: key, feeData: this.feeData } );
Expand All @@ -901,6 +1006,9 @@ export default {
setFee( value, type ) {
this.$store.dispatch( 'Cart/addFeeAction', { title: this.__( 'Fee', 'wepos' ), value: value, type: type } );
},
removeCouponLine( key ) {
this.$store.dispatch( 'Cart/removeCouponLineItemsAction', key );
},
removeFeeLine( key ) {
this.$store.dispatch( 'Cart/removeFeeLineItemsAction', key );
},
Expand Down
Loading

0 comments on commit 485eb95

Please sign in to comment.