@lancom/shared 0.0.174 → 0.0.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -62,8 +62,15 @@ export function getPrintsFromLayers(layers, product) {
|
|
|
62
62
|
return [...prints.values()];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function getPrintTypeSizePricing(printType, sizeId) {
|
|
66
|
-
|
|
65
|
+
export function getPrintTypeSizePricing(printType, sizeId, coupon) {
|
|
66
|
+
let couponPrintArea = null;
|
|
67
|
+
(coupon?.prints || [])
|
|
68
|
+
.forEach(({ printAreas, printTypes }) => {
|
|
69
|
+
if (printTypes.includes(printType._id)) {
|
|
70
|
+
couponPrintArea = couponPrintArea || printAreas.find(({ printSizes }) => printSizes.includes(sizeId))
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return couponPrintArea || (printType?.printAreas || [])
|
|
67
74
|
.find(({ printSizes }) => {
|
|
68
75
|
return printSizes.map(size => size?._id || size).includes(sizeId);
|
|
69
76
|
}) || (printType?.printAreas || [])[0];
|
|
@@ -48,7 +48,15 @@
|
|
|
48
48
|
<div
|
|
49
49
|
v-if="isValidPricing"
|
|
50
50
|
class="lc_h4">
|
|
51
|
-
|
|
51
|
+
<span v-if="value.showCouponIsApplied">
|
|
52
|
+
COUPON APPLIED
|
|
53
|
+
</span>
|
|
54
|
+
<span v-else>
|
|
55
|
+
{{ value.value | price }} OFF
|
|
56
|
+
</span>
|
|
57
|
+
<span
|
|
58
|
+
class="CouponSelect__clear"
|
|
59
|
+
@click="clearCoupon()">remove</span>
|
|
52
60
|
</div>
|
|
53
61
|
<div
|
|
54
62
|
v-else
|
|
@@ -108,6 +116,10 @@ export default {
|
|
|
108
116
|
}
|
|
109
117
|
},
|
|
110
118
|
methods: {
|
|
119
|
+
clearCoupon() {
|
|
120
|
+
this.model = null;
|
|
121
|
+
this.code = null;
|
|
122
|
+
},
|
|
111
123
|
async validateCoupon() {
|
|
112
124
|
this.notValidCoupon = false;
|
|
113
125
|
if (this.code) {
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -218,17 +218,21 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
|
|
|
218
218
|
entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
|
|
219
219
|
_id,
|
|
220
220
|
guid,
|
|
221
|
+
name: product.name,
|
|
221
222
|
brand: getSimpleObj(product.brand),
|
|
222
|
-
simpleProducts: simpleProducts.map(({ _id, guid, amount, pricing, unprintedPricing, weight = 0 }) =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
223
|
+
simpleProducts: simpleProducts.map(({ _id, guid, amount, pricing, unprintedPricing, weight = 0 }) => {
|
|
224
|
+
const couponProduct = (coupon?.products || []).find(({ products }) => products.includes(product._id));
|
|
225
|
+
return {
|
|
226
|
+
amount,
|
|
227
|
+
pricing: couponProduct?.pricing || ((prints || []).length > 0 ? pricing : unprintedPricing),
|
|
228
|
+
weight: product.weight,
|
|
229
|
+
volume: product.volume,
|
|
230
|
+
guid,
|
|
231
|
+
_id
|
|
232
|
+
};
|
|
233
|
+
}).filter(({ amount }) => +amount > 0),
|
|
230
234
|
prints: (prints || []).map(print => {
|
|
231
|
-
const { setupCost, freeSetupOver, printCost } = getPrintTypeSizePricing(print.printType, print.printSize?._id) || {};
|
|
235
|
+
const { setupCost, freeSetupOver, printCost } = getPrintTypeSizePricing(print.printType, print.printSize?._id, coupon) || {};
|
|
232
236
|
return {
|
|
233
237
|
costType: print.printType.costType,
|
|
234
238
|
setupCost,
|
package/store/index.js
CHANGED
|
@@ -56,6 +56,13 @@ export const actions = {
|
|
|
56
56
|
if (state.cart?.id) {
|
|
57
57
|
const cart = await api.fetchCartById(shop._id, state.cart?.id);
|
|
58
58
|
commit('cart/setCart', cart);
|
|
59
|
+
if (state.cart?.coupon) {
|
|
60
|
+
try {
|
|
61
|
+
const code = state.cart?.coupon.code || state.cart?.coupon;
|
|
62
|
+
const coupon = await api.fetchCouponByCode(shop._id, code);
|
|
63
|
+
commit('cart/setCoupon', coupon);
|
|
64
|
+
} catch (e) {}
|
|
65
|
+
}
|
|
59
66
|
dispatch('cart/calculateCartPrice', { shop });
|
|
60
67
|
}
|
|
61
68
|
}
|