@lancom/shared 0.0.307 → 0.0.308
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.
- package/assets/js/api/index.js +2 -2
- package/assets/js/models/print-area.js +7 -5
- package/assets/js/models/product-layers.js +2 -2
- package/assets/js/utils/layers.js +6 -5
- package/components/checkout/order/order-billing-information/order-billing-information.vue +16 -3
- package/components/checkout/order/order-payment-information/order-payment-information.vue +21 -13
- package/components/common/payment/payment_card/payment-card.vue +2 -2
- package/components/common/payment/payment_card/pinpayment/pinpayment.vue +8 -7
- package/components/common/payment/payment_card/stripe_payment/stripe-payment.vue +3 -2
- package/components/common/postcode_select/postcode-select.vue +12 -4
- package/components/editor/editor_workspace/editor_workspace_side/editor-workspace-side.vue +6 -0
- package/components/editor/mobile_editor_product_details/mobile-editor-product-details.vue +1 -1
- package/components/modals/payment_modal/payment-modal.vue +1 -1
- package/components/order/order_payment/order-payment.vue +1 -1
- package/components/product/wizard/wizard.vue +6 -6
- package/mixins/product-view.js +40 -16
- package/package.json +1 -1
- package/store/layers.js +0 -1
- package/store/product.js +10 -8
package/assets/js/api/index.js
CHANGED
|
@@ -95,9 +95,9 @@ const api = {
|
|
|
95
95
|
fetchOrderByToken(token, params) {
|
|
96
96
|
return _get(`order/token/${token}`, params);
|
|
97
97
|
},
|
|
98
|
-
getPaymentIntent(shop, { amount, currency, payment, description }) {
|
|
98
|
+
getPaymentIntent(shop, { amount, currency, payment, description, order }) {
|
|
99
99
|
const url = `shop/${shop}/payment-intent`;
|
|
100
|
-
return _post(url, { amount, currency, payment, description });
|
|
100
|
+
return _post(url, { amount, currency, payment, description, order });
|
|
101
101
|
},
|
|
102
102
|
createOrderPayment(id, { card, shop, country, currency, invoice, payment, recaptchaToken }) {
|
|
103
103
|
const url = invoice ? `shop/${shop}/order/${id}/invoice/${invoice}/payment` : `shop/${shop}/order/${id}/payment`;
|
|
@@ -17,9 +17,9 @@ export const getProductPrintAreas = product => {
|
|
|
17
17
|
if (!product) {
|
|
18
18
|
return {};
|
|
19
19
|
}
|
|
20
|
-
const getSizesFromAreas = (areas, map) => (areas || []).reduce((list, { printSize, printAreaOffsets, sizes, _id }) => {
|
|
20
|
+
const getSizesFromAreas = (areas, map, printAreaSide) => (areas || []).reduce((list, { printSize, side, printAreaOffsets, sizes, _id }) => {
|
|
21
21
|
if (_id && printSize) {
|
|
22
|
-
list[_id] = { printSize, printAreaOffsets };
|
|
22
|
+
list[_id] = { printSize, side: printAreaSide || side, printAreaOffsets };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (sizes) {
|
|
@@ -46,8 +46,10 @@ export const getPrintAreaByName = (params, product) => {
|
|
|
46
46
|
const { printArea, editorWidth, editorHeight, printSize, printAreaOffsets } = params;
|
|
47
47
|
const printAreas = getProductPrintAreas(product);
|
|
48
48
|
const pa = printAreas[printArea] || DEFAULT_PRINT_AREA;
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const printSizeId = printSize?._id || printSize;
|
|
50
|
+
const productPrintArea = product.printAreasOffsets?.find(p => p.printAreas?.includes(printArea) && (!p.printSize || p.printSize === printSizeId));
|
|
51
|
+
const size = productPrintArea?.printAreaSize || (printSize?._id && printSize) || pa.printSize;
|
|
52
|
+
const sideId = productPrintArea?.side || pa.side;
|
|
51
53
|
const offsets = productPrintArea?.printAreaOffsets || printAreaOffsets || pa.printAreaOffsets;
|
|
52
54
|
const pxPerCm = (editorWidth * product.productToImageRatio) / (product.productWidthInCm || 60);
|
|
53
55
|
const widthCm = size ? size.width : DEFAULT_PRINT_SIZE_CM;
|
|
@@ -74,7 +76,7 @@ export const getPrintAreaByName = (params, product) => {
|
|
|
74
76
|
const widthInInches = widthCm * cmToInchesRatio;
|
|
75
77
|
const heightInInches = heightCm * cmToInchesRatio;
|
|
76
78
|
|
|
77
|
-
const info = { width, height, top, left, center, printArea, widthInInches, heightInInches };
|
|
79
|
+
const info = { width, sideId, height, top, left, center, printArea, widthInInches, heightInInches };
|
|
78
80
|
// console.log('getPrintAreaByName:info ', offsets, info, params);
|
|
79
81
|
return info;
|
|
80
82
|
};
|
|
@@ -7,13 +7,14 @@ export function generateLayersTemplate(template, printArea) {
|
|
|
7
7
|
}));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function fitLayerToEditorSize(layer, { size }, { width, height, top, left }) {
|
|
11
|
-
const scaleKoef =
|
|
12
|
-
layer.top = top + layer.top * scaleKoef;
|
|
13
|
-
layer.left = left + layer.left * scaleKoef;
|
|
10
|
+
export function fitLayerToEditorSize(layer, { size }, { width, height, top, left }) {
|
|
11
|
+
const scaleKoef = (width < height ? width / size.width : height / size.height) - 0.02;
|
|
12
|
+
layer.top = top + layer.top * scaleKoef + (Math.abs(size.height * scaleKoef - height) / 2) - 4;
|
|
13
|
+
layer.left = left + layer.left * scaleKoef + Math.abs((size.width * scaleKoef - width) / 2) - 3;
|
|
14
14
|
['fontSize', 'scaleX', 'scaleY'].forEach(property => {
|
|
15
15
|
if (property in layer) {
|
|
16
|
-
|
|
16
|
+
const originalSize = layer[property];
|
|
17
|
+
layer[property] = originalSize * scaleKoef;
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
delete layer.sideId;
|
|
@@ -11,6 +11,19 @@
|
|
|
11
11
|
<address-form
|
|
12
12
|
:address="order.shippingAddress"
|
|
13
13
|
:without-additional-info="true" />
|
|
14
|
+
<checkbox
|
|
15
|
+
v-model="copyToBillingAddress"
|
|
16
|
+
:dark="true">
|
|
17
|
+
<div class="ml-5">Use same address as the billing address</div>
|
|
18
|
+
</checkbox>
|
|
19
|
+
<div
|
|
20
|
+
v-if="!copyToBillingAddress"
|
|
21
|
+
class="mt-7">
|
|
22
|
+
<h5 class="lc_h4 mb-7">Billind Address</h5>
|
|
23
|
+
<address-form
|
|
24
|
+
:address="order.billingAddress"
|
|
25
|
+
:without-additional-info="true" />
|
|
26
|
+
</div>
|
|
14
27
|
</div>
|
|
15
28
|
<div class="Cart__quantity-errors">
|
|
16
29
|
<cart-quantity-errors />
|
|
@@ -49,7 +62,7 @@ export default {
|
|
|
49
62
|
},
|
|
50
63
|
data() {
|
|
51
64
|
return {
|
|
52
|
-
|
|
65
|
+
copyToBillingAddress: true,
|
|
53
66
|
isSubmit: false
|
|
54
67
|
};
|
|
55
68
|
},
|
|
@@ -68,8 +81,8 @@ export default {
|
|
|
68
81
|
const orderInfo = generateOrderData(this.order, this.entities, this.cartPricing);
|
|
69
82
|
gtm.shippingInfo(orderInfo, this.currency);
|
|
70
83
|
|
|
71
|
-
if (this.
|
|
72
|
-
this.order.
|
|
84
|
+
if (this.copyToBillingAddress) {
|
|
85
|
+
this.order.billingAddress = { ...this.order.shippingAddress };
|
|
73
86
|
this.$emit('next');
|
|
74
87
|
// this.$emit('step', ORDER_STEPS.SHIPPING_METHOD);
|
|
75
88
|
} else {
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
{{ errorMessage }}
|
|
55
55
|
</div>
|
|
56
56
|
<div
|
|
57
|
-
v-if="loadingCard"
|
|
57
|
+
v-if="loadingCard || !orderData"
|
|
58
58
|
class="lc_modal__spinner">
|
|
59
59
|
<spinner />
|
|
60
60
|
</div>
|
|
61
61
|
<payment-card
|
|
62
|
-
v-if="
|
|
62
|
+
v-if="orderData"
|
|
63
63
|
ref="paymentCart"
|
|
64
64
|
:amount="cartPricing.totalPrice"
|
|
65
|
-
:
|
|
65
|
+
:order="orderData"
|
|
66
66
|
@inited="initedCard">
|
|
67
67
|
</payment-card>
|
|
68
68
|
<progress-steps-controls
|
|
@@ -121,12 +121,29 @@ export default {
|
|
|
121
121
|
this.order.paymentMethod = this.isDepositPayment ? ORDER_PAYMENT_METHOD.DEPOSIT : ORDER_PAYMENT_METHOD.CART;
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
+
async mounted() {
|
|
125
|
+
await this.initOrderData();
|
|
126
|
+
},
|
|
124
127
|
methods: {
|
|
125
128
|
...mapActions('order', ['createOrder', 'saveOrder']),
|
|
126
129
|
...mapMutations('order', ['setCard']),
|
|
127
130
|
initedCard() {
|
|
128
131
|
this.loadingCard = false;
|
|
129
132
|
},
|
|
133
|
+
async initOrderData() {
|
|
134
|
+
if (!this.orderData) {
|
|
135
|
+
const recaptchaToken = await this.getRecaptcha('create_order');
|
|
136
|
+
await this.createOrder({
|
|
137
|
+
...this.order,
|
|
138
|
+
recaptchaToken,
|
|
139
|
+
products: this.entities,
|
|
140
|
+
pricing: this.cartPricing,
|
|
141
|
+
shop: this.shop._id,
|
|
142
|
+
currency: this.currency?._id,
|
|
143
|
+
country: this.country?._id
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
},
|
|
130
147
|
updatePaymentType(isDeposit) {
|
|
131
148
|
this.isDepositPayment = isDeposit;
|
|
132
149
|
this.errorMessage = null;
|
|
@@ -167,16 +184,7 @@ export default {
|
|
|
167
184
|
try {
|
|
168
185
|
this.creating = true;
|
|
169
186
|
if (!this.orderData) {
|
|
170
|
-
|
|
171
|
-
await this.createOrder({
|
|
172
|
-
...this.order,
|
|
173
|
-
recaptchaToken,
|
|
174
|
-
products: this.entities,
|
|
175
|
-
pricing: this.cartPricing,
|
|
176
|
-
shop: this.shop._id,
|
|
177
|
-
currency: this.currency?._id,
|
|
178
|
-
country: this.country?._id
|
|
179
|
-
});
|
|
187
|
+
await this.initOrderData();
|
|
180
188
|
} else {
|
|
181
189
|
const data = {
|
|
182
190
|
...this.orderData,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<component
|
|
5
5
|
:is="cardComponent"
|
|
6
6
|
ref="card"
|
|
7
|
-
:
|
|
7
|
+
:order="order"
|
|
8
8
|
:amount="amount"
|
|
9
9
|
@inited="$emit('inited')" />
|
|
10
10
|
</client-only>
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
StripePayment: () => import('./stripe_payment/stripe-payment')
|
|
23
23
|
},
|
|
24
24
|
props: {
|
|
25
|
-
|
|
25
|
+
order: {
|
|
26
26
|
type: Object,
|
|
27
27
|
required: true
|
|
28
28
|
},
|
|
@@ -91,7 +91,7 @@ let interval = null;
|
|
|
91
91
|
export default {
|
|
92
92
|
name: 'Payment',
|
|
93
93
|
props: {
|
|
94
|
-
|
|
94
|
+
order: {
|
|
95
95
|
type: Object,
|
|
96
96
|
required: true
|
|
97
97
|
},
|
|
@@ -174,15 +174,16 @@ export default {
|
|
|
174
174
|
tokenize() {
|
|
175
175
|
this.processing = true;
|
|
176
176
|
return new Promise((resolve, reject) => {
|
|
177
|
+
const { shippingAddress } = this.order;
|
|
177
178
|
this.fields.tokenize(
|
|
178
179
|
{
|
|
179
180
|
publishable_api_key: process.env.PINPAYMENT_PUBLISHABLE_API_KEY,
|
|
180
|
-
address_line1:
|
|
181
|
-
address_line2:
|
|
182
|
-
address_city:
|
|
183
|
-
address_postcode:
|
|
184
|
-
address_state:
|
|
185
|
-
address_country:
|
|
181
|
+
address_line1: shippingAddress.addressLine1,
|
|
182
|
+
address_line2: shippingAddress.addressLine2,
|
|
183
|
+
address_city: shippingAddress.city,
|
|
184
|
+
address_postcode: shippingAddress.postcode,
|
|
185
|
+
address_state: shippingAddress.state,
|
|
186
|
+
address_country: shippingAddress.country
|
|
186
187
|
},
|
|
187
188
|
(err, response) => {
|
|
188
189
|
if (!this.processing) {
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
props: {
|
|
24
|
-
|
|
24
|
+
order: {
|
|
25
25
|
type: Object,
|
|
26
26
|
required: true
|
|
27
27
|
},
|
|
@@ -87,7 +87,8 @@ export default {
|
|
|
87
87
|
const params = {
|
|
88
88
|
currency: this.currency?.isoCode,
|
|
89
89
|
amount: this.amount,
|
|
90
|
-
payment: this.payment
|
|
90
|
+
payment: this.payment,
|
|
91
|
+
order: this.order
|
|
91
92
|
};
|
|
92
93
|
const { clientSecret } = await api.getPaymentIntent(this.shop._id, params);
|
|
93
94
|
this.stripe = window.Stripe(this.stripeClientKey);
|
|
@@ -141,6 +141,7 @@ export default {
|
|
|
141
141
|
return this.selected?._id ? this.selected : null;
|
|
142
142
|
},
|
|
143
143
|
set(option) {
|
|
144
|
+
|
|
144
145
|
this.updatePostcode(option);
|
|
145
146
|
}
|
|
146
147
|
}
|
|
@@ -157,7 +158,7 @@ export default {
|
|
|
157
158
|
if (query.trim().length > 1) {
|
|
158
159
|
this.isLoading = true;
|
|
159
160
|
const country = this.codeCountry || this.country;
|
|
160
|
-
const countryName = country ? (['GB','UK'].includes(country.isoCode) ? '
|
|
161
|
+
const countryName = country ? (['GB','UK'].includes(country.isoCode) ? 'UK' : (country.name || country)) : 'Australia';
|
|
161
162
|
const params = {
|
|
162
163
|
query: query.trim(),
|
|
163
164
|
country: countryName
|
|
@@ -182,9 +183,16 @@ export default {
|
|
|
182
183
|
async updatePostcode(option) {
|
|
183
184
|
this.selected = option;
|
|
184
185
|
if (!option.value) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
try {
|
|
187
|
+
this.isLoading = true;
|
|
188
|
+
const suburb = await api.fetchAddressInfo(option._id, this.shop?._id);
|
|
189
|
+
this.$emit('input', suburb.postcode);
|
|
190
|
+
this.$emit('select', suburb);
|
|
191
|
+
option.label = this.createOptionFromSuburb(suburb).label;
|
|
192
|
+
} catch (e) {
|
|
193
|
+
} finally {
|
|
194
|
+
this.isLoading = false;
|
|
195
|
+
}
|
|
188
196
|
} else {
|
|
189
197
|
this.$emit('input', option.value);
|
|
190
198
|
this.$emit('select', this.suburbs.find(({ _id }) => _id === option._id));
|
|
@@ -132,6 +132,9 @@ export default {
|
|
|
132
132
|
'editorSize',
|
|
133
133
|
'editModeSelectedLayer'
|
|
134
134
|
]),
|
|
135
|
+
editableLayersCount() {
|
|
136
|
+
return this.editableLayers?.length;
|
|
137
|
+
},
|
|
135
138
|
hasWireframeImage() {
|
|
136
139
|
return !!this.wireframeImage;
|
|
137
140
|
},
|
|
@@ -197,6 +200,9 @@ export default {
|
|
|
197
200
|
layers() {
|
|
198
201
|
this.redrawWithThrottle();
|
|
199
202
|
},
|
|
203
|
+
editableLayersCount() {
|
|
204
|
+
this.redraw();
|
|
205
|
+
},
|
|
200
206
|
selectedLayer() {
|
|
201
207
|
this.redrawWithThrottle();
|
|
202
208
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="Wizard__wrapper">
|
|
3
3
|
<div
|
|
4
|
-
v-if="
|
|
4
|
+
v-if="preSetPrints"
|
|
5
5
|
class="Wizard__header Wizard__header--active">
|
|
6
6
|
<div class="Wizard__header-name">
|
|
7
7
|
PRINT OPTIONS
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
@edit="editLayer($event)"
|
|
44
44
|
@delete="removeTemplateLayer($event)" />
|
|
45
45
|
<div
|
|
46
|
-
v-if="!
|
|
46
|
+
v-if="!preSetPrints"
|
|
47
47
|
class="Wizard__layers-info">
|
|
48
48
|
<p>1. Note final print price will be calculated once garment quantity is finalised</p>
|
|
49
49
|
<p>2. PDF mockup will be provided for approval prior to printing</p>
|
|
@@ -180,7 +180,7 @@ export default {
|
|
|
180
180
|
},
|
|
181
181
|
computed: {
|
|
182
182
|
...mapGetters(['shop']),
|
|
183
|
-
...mapGetters('product', ['product', 'layers', 'visibleSteps', 'hasLayers', 'isPrintPricing', 'availablePrintTypes', '
|
|
183
|
+
...mapGetters('product', ['product', 'layers', 'visibleSteps', 'hasLayers', 'isPrintPricing', 'availablePrintTypes', 'preSetPrints']),
|
|
184
184
|
steps() {
|
|
185
185
|
const isScreenPrint = (this.availablePrintTypes || []).includes('screen print');
|
|
186
186
|
return isScreenPrint ? WIZARD_STEPS_LIST.filter(s => s !== WIZARD_STEPS.PRINT_SIZE) : WIZARD_STEPS_LIST.filter(s => s !== WIZARD_STEPS.PRINT_UNDERBASE);
|
|
@@ -193,7 +193,7 @@ export default {
|
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
mounted() {
|
|
196
|
-
if (this.product.printOnly || this.
|
|
196
|
+
if (this.product.printOnly || this.preSetPrints || this.layers.length > 0) {
|
|
197
197
|
this.isVisible = true;
|
|
198
198
|
this.setIsPrintPricing(this.isVisible);
|
|
199
199
|
}
|
|
@@ -214,7 +214,7 @@ export default {
|
|
|
214
214
|
'setVisibleSteps',
|
|
215
215
|
'setIsPrintPricing',
|
|
216
216
|
'clearTemplateLayers',
|
|
217
|
-
'
|
|
217
|
+
'setPreSetPrints'
|
|
218
218
|
]),
|
|
219
219
|
...mapMutations('layers', ['setEditableLayers']),
|
|
220
220
|
goToNextStep() {
|
|
@@ -262,7 +262,7 @@ export default {
|
|
|
262
262
|
}
|
|
263
263
|
},
|
|
264
264
|
removePreSetPrint() {
|
|
265
|
-
this.
|
|
265
|
+
this.setPreSetPrints(null);
|
|
266
266
|
this.clearTemplateLayers();
|
|
267
267
|
}
|
|
268
268
|
}
|
package/mixins/product-view.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { mapGetters, createNamespacedHelpers } from 'vuex';
|
|
2
2
|
import gtm from '@lancom/shared/assets/js/utils/gtm';
|
|
3
|
+
import { fitLayerToEditorSize } from '@lancom/shared/assets/js/utils/layers';
|
|
4
|
+
import { getPrintAreaByName } from '@lancom/shared/assets/js/models/print-area';
|
|
3
5
|
import { getLayerModel } from '@lancom/shared/assets/js/models/product-layers';
|
|
4
6
|
import { tax, staticLink, inRange } from '@lancom/shared/assets/js/utils/filters';
|
|
5
7
|
import { getProductLargeCover } from '@lancom/shared/assets/js/utils/colors';
|
|
@@ -63,7 +65,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING) => ({
|
|
|
63
65
|
},
|
|
64
66
|
computed: {
|
|
65
67
|
...mapGetters(['shop', 'gstTax', 'country', 'currency']),
|
|
66
|
-
...mapGetters('product', ['product', 'simpleProducts', 'productDetails', 'editableColor', 'images', '
|
|
68
|
+
...mapGetters('product', ['product', 'simpleProducts', 'productDetails', 'editableColor', 'images', 'preSetPrints', 'preSetPrintsPriceRange', 'editorSize']),
|
|
67
69
|
pageItemImage() {
|
|
68
70
|
return this.mainProductImageSrc;
|
|
69
71
|
},
|
|
@@ -107,22 +109,44 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING) => ({
|
|
|
107
109
|
await this.fetchProductDetails(data);
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
try {
|
|
113
|
+
if (this.preSetPrints) {
|
|
114
|
+
for (const preSetPrint of this.preSetPrints) {
|
|
115
|
+
const layers = preSetPrint.printTemplate?.layers || [{ type: 'text' }];
|
|
116
|
+
for (const layer of layers) {
|
|
117
|
+
const properties = {
|
|
118
|
+
...layer,
|
|
119
|
+
printArea: preSetPrint.printArea,
|
|
120
|
+
printSize: preSetPrint.printSize,
|
|
121
|
+
printType: preSetPrint.printType,
|
|
122
|
+
required: true
|
|
123
|
+
};
|
|
124
|
+
delete properties.guid;
|
|
125
|
+
if (preSetPrint.printTemplate) {
|
|
126
|
+
const printArea = getPrintAreaByName({
|
|
127
|
+
printArea: preSetPrint.printArea,
|
|
128
|
+
printSize: preSetPrint.printSize,
|
|
129
|
+
// printAreaOffsets: printArea?.printAreaOffsets,
|
|
130
|
+
editorWidth: this.editorSize.width,
|
|
131
|
+
editorHeight: this.editorSize.height
|
|
132
|
+
}, this.product);
|
|
133
|
+
fitLayerToEditorSize(properties, preSetPrint.printTemplate, printArea);
|
|
134
|
+
properties.sideId = printArea?.sideId;
|
|
135
|
+
}
|
|
136
|
+
const data = {
|
|
137
|
+
colorId: this.editableColor._id,
|
|
138
|
+
type: layer.type || 'text',
|
|
139
|
+
sideId: properties.sideId || 'front',
|
|
140
|
+
properties
|
|
141
|
+
};
|
|
142
|
+
const model = await getLayerModel(data);
|
|
143
|
+
this.addTemplateLayer(model);
|
|
144
|
+
}
|
|
121
145
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this.addTemplateLayer(layer);
|
|
146
|
+
}
|
|
147
|
+
} catch (e) {
|
|
125
148
|
}
|
|
149
|
+
|
|
126
150
|
this.fillBreadcrumbs();
|
|
127
151
|
|
|
128
152
|
if (multipack) {
|
|
@@ -185,7 +209,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING) => ({
|
|
|
185
209
|
name,
|
|
186
210
|
offers: this.productDetails?.simpleProducts.map(sp => {
|
|
187
211
|
const spMaxPrice = (sp.pricing || []).reduce((price, pricing) => Math.max(price, pricing.price), 0);
|
|
188
|
-
const maxPrice = this.
|
|
212
|
+
const maxPrice = this.preSetPrints ? spMaxPrice + this.preSetPrintsPriceRange.max : spMaxPrice;
|
|
189
213
|
const availability = sp.quantityStock > 0 ? 'InStock' : 'OutOfStock';
|
|
190
214
|
|
|
191
215
|
const offer = {
|
package/package.json
CHANGED
package/store/layers.js
CHANGED
package/store/product.js
CHANGED
|
@@ -15,7 +15,7 @@ export const state = () => ({
|
|
|
15
15
|
images: [],
|
|
16
16
|
priceIncludeGST: false,
|
|
17
17
|
product: null,
|
|
18
|
-
|
|
18
|
+
preSetPrints: null,
|
|
19
19
|
loadError: null,
|
|
20
20
|
productDetails: null,
|
|
21
21
|
editorSize: {
|
|
@@ -52,8 +52,9 @@ export const getters = {
|
|
|
52
52
|
multipack: ({ multipack }) => multipack,
|
|
53
53
|
calculatingPrice: ({ calculatingPrice }) => calculatingPrice,
|
|
54
54
|
product: ({ product }) => product,
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
preSetPrints: ({ preSetPrints }) => preSetPrints,
|
|
56
|
+
preSetPrintsPriceRange: ({ preSetPrints, product }) => {
|
|
57
|
+
const [preSetPrint] = preSetPrints || [];
|
|
57
58
|
const printType = product.printTypes.find(pt => pt._id === preSetPrint?.printType);
|
|
58
59
|
const { printCost = [] } = (printType?.printAreas || [])
|
|
59
60
|
.find(({ printSizes }) => (printSizes || []).some(ps => ps?._id === preSetPrint?.printSize)) || {};
|
|
@@ -159,7 +160,7 @@ export const actions = {
|
|
|
159
160
|
const query = { country, currency };
|
|
160
161
|
const product = await api.fetchProduct(shop, slug, query);
|
|
161
162
|
commit('setProduct', product);
|
|
162
|
-
commit('
|
|
163
|
+
commit('setPreSetPrints', (product.prints || []).filter(({ _id, printTemplate }) => _id === print || (!print && !!printTemplate)));
|
|
163
164
|
} catch (e) {
|
|
164
165
|
console.log(e);
|
|
165
166
|
const { status, data } = e?.response || {};
|
|
@@ -279,7 +280,8 @@ export const mutations = {
|
|
|
279
280
|
state.loadError = error;
|
|
280
281
|
},
|
|
281
282
|
setProductDetails(state, simpleProducts) {
|
|
282
|
-
const {
|
|
283
|
+
const { preSetPrints } = state;
|
|
284
|
+
const [preSetPrint] = preSetPrints || [];
|
|
283
285
|
simpleProducts = simpleProducts.filter(sp => !preSetPrint || (preSetPrint.colors || []).includes(sp.color._id) )
|
|
284
286
|
state.productDetails = { simpleProducts };
|
|
285
287
|
const availableSizes = [];
|
|
@@ -364,7 +366,7 @@ export const mutations = {
|
|
|
364
366
|
...(state.template.layers || []).filter(l => l.guid !== layer.guid),
|
|
365
367
|
layer
|
|
366
368
|
];
|
|
367
|
-
|
|
369
|
+
state.template = { ...state.template, layers };
|
|
368
370
|
if (layers.length === 1 && !state.product.printOnly) {
|
|
369
371
|
// const printType = state.product.printTypes[0];
|
|
370
372
|
// state.selectedPrintType = printType;
|
|
@@ -492,8 +494,8 @@ export const mutations = {
|
|
|
492
494
|
setVisibleSteps(state, visibleSteps) {
|
|
493
495
|
state.template.visibleSteps = visibleSteps;
|
|
494
496
|
},
|
|
495
|
-
|
|
496
|
-
state.
|
|
497
|
+
setPreSetPrints(state, preSetPrints) {
|
|
498
|
+
state.preSetPrints = preSetPrints;
|
|
497
499
|
},
|
|
498
500
|
setEditableSide(state, side) {
|
|
499
501
|
state.editableSide = side;
|