@lancom/shared 0.0.464 → 0.0.466
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/admin.js +4 -1
- package/assets/js/constants/print-type.js +2 -1
- package/components/checkout/cart/cart.mixin.js +5 -1
- package/components/checkout/cart/cart.vue +2 -2
- package/components/checkout/order/order.vue +2 -2
- package/components/common/pricing_discounts_table/pricing-discounts-table.scss +14 -1
- package/components/common/pricing_discounts_table/pricing-discounts-table.vue +23 -1
- package/components/order/order_view/order-view.scss +3 -6
- package/components/order/order_view/order-view.vue +6 -2
- package/components/product/add-to-cart-btn-guarded/add-to-cart-btn-guarded.vue +62 -0
- package/components/product/editor_pricing/editor-pricing.vue +27 -5
- package/components/product/gallery/gallery.scss +8 -8
- package/components/product/product_size_selector/product_size_selector_color/product_size_selector_color_cell/product-size-selector-color-cell.vue +3 -2
- package/components/product/wizard/wizard_print/wizard-print.vue +3 -2
- package/components/products/products_aside/products-aside.vue +1 -1
- package/components/products/products_link/products-link.vue +3 -3
- package/mixins/product-preview.js +4 -0
- package/mixins/product-view.js +4 -3
- package/package.json +1 -1
- package/plugins/save-state.js +0 -1
- package/store/cart.js +28 -19
- package/store/index.js +34 -10
package/assets/js/api/admin.js
CHANGED
|
@@ -128,6 +128,9 @@ export default {
|
|
|
128
128
|
orderSubOrders(body) {
|
|
129
129
|
return _post('admin/sub-orders/ordered', body);
|
|
130
130
|
},
|
|
131
|
+
saveSubOrder(subOrder) {
|
|
132
|
+
return _put(`admin/sub-order/${subOrder._id}`, subOrder);
|
|
133
|
+
},
|
|
131
134
|
generateOrderPickPDF(orderId) {
|
|
132
135
|
return _post(`admin/order/${orderId}/pick-pdf`);
|
|
133
136
|
},
|
|
@@ -312,7 +315,7 @@ export default {
|
|
|
312
315
|
return _delete(`admin/inventory-history/${id}`);
|
|
313
316
|
},
|
|
314
317
|
fetchInventory(params) {
|
|
315
|
-
return _get('admin/inventory');
|
|
318
|
+
return _get('admin/inventory', params);
|
|
316
319
|
},
|
|
317
320
|
fetchProducts(params) {
|
|
318
321
|
return _get('admin/products', params);
|
|
@@ -2,7 +2,8 @@ export const PRINT_TYPES = {
|
|
|
2
2
|
BLACK: 'black print',
|
|
3
3
|
FULL_COLOUR: 'full colour print',
|
|
4
4
|
EMBROIDERY: 'embroidery',
|
|
5
|
-
SCREEN: 'screen print'
|
|
5
|
+
SCREEN: 'screen print',
|
|
6
|
+
REFLECTIVE: 'reflective'
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
export const PRINT_TYPES_LIST = Object.keys(PRINT_TYPES).map(k => PRINT_TYPES[k]);
|
|
@@ -16,6 +16,7 @@ export default {
|
|
|
16
16
|
...mapGetters(['shop', 'country', 'currency']),
|
|
17
17
|
...mapGetters('auth', ['user']),
|
|
18
18
|
...mapGetters('cart', [
|
|
19
|
+
'loadingCart',
|
|
19
20
|
'needToPickup',
|
|
20
21
|
'needToPickupWithoutErrors',
|
|
21
22
|
'entities',
|
|
@@ -60,7 +61,10 @@ export default {
|
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
mounted() {
|
|
63
|
-
|
|
64
|
+
// console.log('this.loadingCart: ', this.loadingCart);
|
|
65
|
+
// if (!this.loadingCart) {
|
|
66
|
+
// this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
|
|
67
|
+
// }
|
|
64
68
|
if (!this.suburb && this.user?.suburb) {
|
|
65
69
|
this.handleSuburbChange(this.user.suburb);
|
|
66
70
|
}
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
<div
|
|
78
78
|
v-else
|
|
79
79
|
class="lc_caption lc_text-centered Cart__no-entities">
|
|
80
|
-
Your cart is empty.
|
|
80
|
+
{{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
83
83
|
</template>
|
|
@@ -115,7 +115,7 @@ export default {
|
|
|
115
115
|
},
|
|
116
116
|
computed: {
|
|
117
117
|
...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
|
|
118
|
-
...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts']),
|
|
118
|
+
...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts', 'loadingCart']),
|
|
119
119
|
productsEntities() {
|
|
120
120
|
return this.entitiesWithoutFreeProducts.filter(e => !e.productsKit);
|
|
121
121
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<div
|
|
31
31
|
v-else
|
|
32
32
|
class="lc_caption lc_text-centered Cart__no-entities">
|
|
33
|
-
Your cart is empty.
|
|
33
|
+
{{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</template>
|
|
@@ -83,7 +83,7 @@ export default {
|
|
|
83
83
|
},
|
|
84
84
|
computed: {
|
|
85
85
|
...mapGetters('country'),
|
|
86
|
-
...mapGetters('cart', ['isEmpty']),
|
|
86
|
+
...mapGetters('cart', ['isEmpty', 'loadingCart']),
|
|
87
87
|
...mapGetters('order', ['orderData']),
|
|
88
88
|
...mapGetters('auth', ['isAuthenticated', 'user']),
|
|
89
89
|
steps() {
|
|
@@ -2,4 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
table {
|
|
4
4
|
min-width: 200px;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.PricingDiscountsTable__see-more {
|
|
8
|
+
text-align: center;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
color: $link;
|
|
12
|
+
padding: 4px 0;
|
|
13
|
+
user-select: none;
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
text-decoration: underline;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</thead>
|
|
12
12
|
<tbody class="centered">
|
|
13
13
|
<tr
|
|
14
|
-
v-for="(range, index) in
|
|
14
|
+
v-for="(range, index) in visiblePrices"
|
|
15
15
|
:key="range.min"
|
|
16
16
|
:class="{
|
|
17
17
|
active: amount >= range.min && ((range.max && amount <= range.max) || !range.max)
|
|
@@ -46,6 +46,16 @@
|
|
|
46
46
|
</td>
|
|
47
47
|
</tr>
|
|
48
48
|
</tbody>
|
|
49
|
+
<tfoot v-if="limit && prices.length > limit">
|
|
50
|
+
<tr>
|
|
51
|
+
<td
|
|
52
|
+
:colspan="visibleDiscount ? 3 : 2"
|
|
53
|
+
class="PricingDiscountsTable__see-more"
|
|
54
|
+
@click="showAll = !showAll">
|
|
55
|
+
{{ showAll ? 'Show less' : `See more (${prices.length - limit})` }}
|
|
56
|
+
</td>
|
|
57
|
+
</tr>
|
|
58
|
+
</tfoot>
|
|
49
59
|
</table>
|
|
50
60
|
</template>
|
|
51
61
|
|
|
@@ -91,14 +101,26 @@ export default {
|
|
|
91
101
|
priceLabel: {
|
|
92
102
|
type: String,
|
|
93
103
|
default: 'Price'
|
|
104
|
+
},
|
|
105
|
+
limit: {
|
|
106
|
+
type: Number,
|
|
107
|
+
default: 4
|
|
94
108
|
}
|
|
95
109
|
},
|
|
110
|
+
data() {
|
|
111
|
+
return {
|
|
112
|
+
showAll: false
|
|
113
|
+
};
|
|
114
|
+
},
|
|
96
115
|
computed: {
|
|
97
116
|
...mapGetters([
|
|
98
117
|
'pricingSettings'
|
|
99
118
|
]),
|
|
100
119
|
maxPrice() {
|
|
101
120
|
return this.prices?.[0]?.price || 0;
|
|
121
|
+
},
|
|
122
|
+
visiblePrices() {
|
|
123
|
+
return this.limit && !this.showAll ? this.prices.slice(0, this.limit) : this.prices;
|
|
102
124
|
}
|
|
103
125
|
}
|
|
104
126
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
.OrderView {
|
|
2
|
-
&__wrapper {
|
|
3
|
-
margin-top: 50px;
|
|
4
|
-
}
|
|
5
2
|
&__logo {
|
|
6
3
|
margin-bottom: 10px;
|
|
7
4
|
}
|
|
@@ -12,7 +9,7 @@
|
|
|
12
9
|
}
|
|
13
10
|
&__table {
|
|
14
11
|
margin-top: 20px;
|
|
15
|
-
td {
|
|
12
|
+
td {
|
|
16
13
|
width: 50%;
|
|
17
14
|
padding: 20px;
|
|
18
15
|
}
|
|
@@ -42,7 +39,7 @@
|
|
|
42
39
|
align-items: flex-end;
|
|
43
40
|
&--paid {
|
|
44
41
|
background-image: url(../../../static/images/paid.svg);
|
|
45
|
-
background-repeat: no-repeat;
|
|
42
|
+
background-repeat: no-repeat;
|
|
46
43
|
background-position: 0px 0px;
|
|
47
44
|
background-size: 500px;
|
|
48
45
|
}
|
|
@@ -54,4 +51,4 @@
|
|
|
54
51
|
}
|
|
55
52
|
.uppercase {
|
|
56
53
|
text-transform: uppercase;
|
|
57
|
-
}
|
|
54
|
+
}
|
|
@@ -181,7 +181,9 @@
|
|
|
181
181
|
<div class="lc_regular16">
|
|
182
182
|
Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
183
183
|
</div>
|
|
184
|
-
<div
|
|
184
|
+
<div
|
|
185
|
+
class="lc_regular16"
|
|
186
|
+
style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
|
|
185
187
|
{{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
186
188
|
</div>
|
|
187
189
|
</div>
|
|
@@ -229,7 +231,9 @@
|
|
|
229
231
|
<div class="lc_regular16">
|
|
230
232
|
Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
231
233
|
</div>
|
|
232
|
-
<div
|
|
234
|
+
<div
|
|
235
|
+
class="lc_regular16"
|
|
236
|
+
style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
|
|
233
237
|
{{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
234
238
|
</div>
|
|
235
239
|
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="AddToCartBtnGuarded__wrapper">
|
|
3
|
+
<add-to-cart-btn
|
|
4
|
+
v-if="!addToCartDisabled || !clicked"
|
|
5
|
+
:btn-class="btnClass"
|
|
6
|
+
:allow-click="!clicked"
|
|
7
|
+
@proceed="onProceed">
|
|
8
|
+
<template
|
|
9
|
+
v-if="$slots['icon-before']"
|
|
10
|
+
#icon-before>
|
|
11
|
+
<slot name="icon-before" />
|
|
12
|
+
</template>
|
|
13
|
+
</add-to-cart-btn>
|
|
14
|
+
<v-popover
|
|
15
|
+
v-else
|
|
16
|
+
trigger="hover"
|
|
17
|
+
:delay="{ hide: 400, show: 400 }">
|
|
18
|
+
<add-to-cart-btn :btn-class="btnClass">
|
|
19
|
+
<template
|
|
20
|
+
v-if="$slots['icon-before']"
|
|
21
|
+
#icon-before>
|
|
22
|
+
<slot name="icon-before" />
|
|
23
|
+
</template>
|
|
24
|
+
</add-to-cart-btn>
|
|
25
|
+
<template slot="popover">
|
|
26
|
+
<slot name="popover-message">
|
|
27
|
+
<p>You've not added any art or text to print. We only sell custom printed products.</p>
|
|
28
|
+
</slot>
|
|
29
|
+
</template>
|
|
30
|
+
</v-popover>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
36
|
+
import AddToCartBtn from '@lancom/shared/components/product/add-to-cart-btn';
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
name: 'AddToCartBtnGuarded',
|
|
40
|
+
components: {
|
|
41
|
+
AddToCartBtn
|
|
42
|
+
},
|
|
43
|
+
mixins: [addToCartMixin],
|
|
44
|
+
props: {
|
|
45
|
+
btnClass: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: 'green'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
clicked: false
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
onProceed(result) {
|
|
57
|
+
this.clicked = true;
|
|
58
|
+
this.$emit('proceed', result);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
</script>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<editor-pricing-details />
|
|
8
8
|
</div>
|
|
9
9
|
<div
|
|
10
|
-
v-if="visibleAlert"
|
|
10
|
+
v-if="visibleAlert || forceAlert"
|
|
11
11
|
class="EditorPricing__alerts-wrapper">
|
|
12
12
|
<div
|
|
13
13
|
v-if="addedToCart"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
v-else-if="!isValidOrderQuantity && isValidBigSizeOrderQuantity && minimumOrderQuantity > 1"
|
|
53
53
|
class="EditorPricing__main-alert">
|
|
54
54
|
<img src="~static/images/sad.svg" />
|
|
55
|
-
Minimum order of these items must be {{ minimumOrderQuantity }} or more
|
|
55
|
+
Minimum order {{ selectedPrintTypeNames.length ? `for ${selectedPrintTypeNames.join(', ')}` : 'of these items' }} must be {{ minimumOrderQuantity }} or more
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
58
|
<div
|
|
@@ -68,6 +68,13 @@
|
|
|
68
68
|
<img src="~static/images/smile.svg" />
|
|
69
69
|
{{ hasPrintIssues ? 'Proceed with order, Will be in touch regarding print issue' : 'All good to go!' }}
|
|
70
70
|
</div>
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
v-else-if="!hasUsedSimpleProducts && forceAlert"
|
|
74
|
+
class="EditorPricing__main-alert">
|
|
75
|
+
<img src="~static/images/sad.svg" />
|
|
76
|
+
No products selected
|
|
77
|
+
</div>
|
|
71
78
|
</div>
|
|
72
79
|
<div
|
|
73
80
|
v-if="product.isClearance || clearanceColorsWithQty.length > 0"
|
|
@@ -106,9 +113,14 @@
|
|
|
106
113
|
{{ showDetails ? 'Hide' : 'Show' }} detail
|
|
107
114
|
</div>
|
|
108
115
|
<slot>
|
|
109
|
-
<add-to-cart-btn
|
|
116
|
+
<add-to-cart-btn-guarded
|
|
110
117
|
v-if="hasCartBtn"
|
|
111
|
-
class="EditorPricing__add-to-cart-button"
|
|
118
|
+
class="EditorPricing__add-to-cart-button"
|
|
119
|
+
@proceed="forceAlert = !$event">
|
|
120
|
+
<template #popover-message>
|
|
121
|
+
<p>Please select your product colours & quantities and add your artwork or text before adding to cart.</p>
|
|
122
|
+
</template>
|
|
123
|
+
</add-to-cart-btn-guarded>
|
|
112
124
|
</slot>
|
|
113
125
|
</div>
|
|
114
126
|
</div>
|
|
@@ -121,6 +133,7 @@ import { mapGetters, mapActions } from 'vuex';
|
|
|
121
133
|
import debounce from 'lodash.debounce';
|
|
122
134
|
import { price, sizesRange, printsRange, tax } from '@lancom/shared/assets/js/utils/filters';
|
|
123
135
|
import AddToCartBtn from '@lancom/shared/components/product/add-to-cart-btn';
|
|
136
|
+
import AddToCartBtnGuarded from '@lancom/shared/components/product/add-to-cart-btn-guarded/add-to-cart-btn-guarded';
|
|
124
137
|
import EditorPricingDetails from '@lancom/shared/components/editor/editor_pricing/editor_pricing_details/editor-pricing-details';
|
|
125
138
|
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
126
139
|
|
|
@@ -134,7 +147,8 @@ export default {
|
|
|
134
147
|
},
|
|
135
148
|
components: {
|
|
136
149
|
EditorPricingDetails,
|
|
137
|
-
AddToCartBtn
|
|
150
|
+
AddToCartBtn,
|
|
151
|
+
AddToCartBtnGuarded
|
|
138
152
|
},
|
|
139
153
|
mixins: [addToCartMixin],
|
|
140
154
|
props: {
|
|
@@ -154,6 +168,7 @@ export default {
|
|
|
154
168
|
data() {
|
|
155
169
|
return {
|
|
156
170
|
clickedAddToCart: false,
|
|
171
|
+
forceAlert: false,
|
|
157
172
|
price: null,
|
|
158
173
|
showDetails: false,
|
|
159
174
|
calculatePriceWithDebounce: debounce(() => this.calculateProductPrice({ shop: this.shop, country: this.country, currency: this.currency }), 500)
|
|
@@ -181,6 +196,13 @@ export default {
|
|
|
181
196
|
hasPrintIssues() {
|
|
182
197
|
return this.offsetWarningVisible || this.showRecommendationToUseLargerImage || this.showErrorAboutSmallImage;
|
|
183
198
|
},
|
|
199
|
+
selectedPrintTypeNames() {
|
|
200
|
+
const layerPrintTypeIds = (this.layers || []).map(l => l.printType?._id || l.printType).filter(Boolean);
|
|
201
|
+
return (this.product.printTypes || [])
|
|
202
|
+
.filter(pt => layerPrintTypeIds.includes(pt._id || pt))
|
|
203
|
+
.map(pt => pt.name)
|
|
204
|
+
.filter(Boolean);
|
|
205
|
+
},
|
|
184
206
|
hasUsedSimpleProducts() {
|
|
185
207
|
return this.usedSimpleProducts.length > 0;
|
|
186
208
|
},
|
|
@@ -201,10 +201,10 @@
|
|
|
201
201
|
}
|
|
202
202
|
&__zoom-image {
|
|
203
203
|
position: absolute;
|
|
204
|
-
right: -
|
|
204
|
+
right: -200px;
|
|
205
205
|
top: 0;
|
|
206
|
-
width:
|
|
207
|
-
height:
|
|
206
|
+
width: 500px;
|
|
207
|
+
height: 500px;
|
|
208
208
|
z-index: 2;
|
|
209
209
|
background-color: white;
|
|
210
210
|
box-shadow: 0 0 10px gray;
|
|
@@ -212,14 +212,14 @@
|
|
|
212
212
|
pointer-events: none;
|
|
213
213
|
img {
|
|
214
214
|
position: absolute;
|
|
215
|
-
max-width:
|
|
216
|
-
max-height:
|
|
215
|
+
max-width: 1000px;
|
|
216
|
+
max-height: 1000px;
|
|
217
217
|
}
|
|
218
218
|
&.preview {
|
|
219
219
|
img {
|
|
220
|
-
max-width:
|
|
221
|
-
max-height:
|
|
220
|
+
max-width: 500px;
|
|
221
|
+
max-height: 500px;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
}
|
|
225
|
+
}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
:aria-label="size.name"
|
|
29
29
|
:disabled="disabled"
|
|
30
30
|
@wheel="onWheel"
|
|
31
|
-
@focus="onFocus()"
|
|
31
|
+
@focus="onFocus($event)"
|
|
32
32
|
@blur="onBlur()" />
|
|
33
33
|
<div
|
|
34
34
|
class="ProductSizeSelectorColorCell__side-control ProductSizeSelectorColorCell__side-control--right"
|
|
@@ -141,7 +141,8 @@ export default {
|
|
|
141
141
|
onWheel(e) {
|
|
142
142
|
e.target.blur();
|
|
143
143
|
},
|
|
144
|
-
onFocus() {
|
|
144
|
+
onFocus(e) {
|
|
145
|
+
this.$nextTick(() => e.target.select());
|
|
145
146
|
this.defaultValue = '';
|
|
146
147
|
},
|
|
147
148
|
onBlur() {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
<script>
|
|
60
60
|
import { mapGetters, mapMutations } from 'vuex';
|
|
61
61
|
import Info from '@lancom/shared/components/common/info-popover';
|
|
62
|
+
import { SETTINGS } from '@/settings';
|
|
62
63
|
|
|
63
64
|
export default {
|
|
64
65
|
name: 'WizardPrint',
|
|
@@ -68,7 +69,7 @@ export default {
|
|
|
68
69
|
data() {
|
|
69
70
|
return {
|
|
70
71
|
orderPrintTypes: [{
|
|
71
|
-
types: ['black print', 'full colour print'],
|
|
72
|
+
types: ['black print', 'full colour print', 'reflective'],
|
|
72
73
|
icon: 'printed',
|
|
73
74
|
name: 'DIGITAL',
|
|
74
75
|
subName: '',
|
|
@@ -76,7 +77,7 @@ export default {
|
|
|
76
77
|
'Free Setup on all Black prints',
|
|
77
78
|
'Standard turn around time of 5-10 days',
|
|
78
79
|
'Same or next day rush service available',
|
|
79
|
-
|
|
80
|
+
`Pickup from warehouse in ${SETTINGS?.DEFAULT_PICKUP_WAREHOUSE || 'Mount Druitt'}`
|
|
80
81
|
]
|
|
81
82
|
// info: 'DIGITAL - minimum 12'
|
|
82
83
|
}, {
|
package/mixins/product-view.js
CHANGED
|
@@ -144,6 +144,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
|
|
|
144
144
|
if (!this.product) {
|
|
145
145
|
const query = this.getProductQuery();
|
|
146
146
|
await this.fetchProduct(query);
|
|
147
|
+
await this.fetchProductDetails(query);
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
await this.loadProductStockDetails();
|
|
@@ -213,7 +214,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
|
|
|
213
214
|
...mapMutations(['clearProduct', 'clearTemplate', 'addTemplateLayer', 'setSimpleProductAmount', 'setPriceIncludeGST']),
|
|
214
215
|
staticLink,
|
|
215
216
|
getProductQuery() {
|
|
216
|
-
const
|
|
217
|
+
const slug = this.slug || this.$route.params.slug;
|
|
217
218
|
const { color, colour, size } = this.$route.query;
|
|
218
219
|
const data = {
|
|
219
220
|
shop: this.shop._id,
|
|
@@ -221,8 +222,8 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
|
|
|
221
222
|
country: this.country?._id,
|
|
222
223
|
stockCountry: this.stockCountry?._id,
|
|
223
224
|
currency: this.currency?._id,
|
|
224
|
-
defaultColor: color || colour,
|
|
225
|
-
defaultSize: size
|
|
225
|
+
defaultColor: this.defaultColor || color || colour,
|
|
226
|
+
defaultSize: this.defaultSize || size
|
|
226
227
|
};
|
|
227
228
|
|
|
228
229
|
return data;
|
package/package.json
CHANGED
package/plugins/save-state.js
CHANGED
package/store/cart.js
CHANGED
|
@@ -11,6 +11,7 @@ export const state = () => ({
|
|
|
11
11
|
id: null,
|
|
12
12
|
entities: [],
|
|
13
13
|
needToPickup: false,
|
|
14
|
+
loadingCart: false,
|
|
14
15
|
suburb: null,
|
|
15
16
|
coupon: null,
|
|
16
17
|
cartPricingCalculating: false,
|
|
@@ -103,6 +104,7 @@ export const getters = {
|
|
|
103
104
|
return freeProducts.length > 0 ? sum + amount : sum;
|
|
104
105
|
}, 0);
|
|
105
106
|
},
|
|
107
|
+
loadingCart: ({ loadingCart }) => loadingCart,
|
|
106
108
|
coupon: ({ coupon }) => coupon,
|
|
107
109
|
needToPickup: ({ needToPickup }) => needToPickup,
|
|
108
110
|
needToPickupWithoutErrors: (state, { notValidProductsPickup }) => state.needToPickup && notValidProductsPickup?.length === 0,
|
|
@@ -229,25 +231,28 @@ export const actions = {
|
|
|
229
231
|
await api.saveCart(payload, shop._id);
|
|
230
232
|
commit('setCartSaving', false);
|
|
231
233
|
},
|
|
232
|
-
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, getters: { needToPickup }, commit }, { shop, country, currency }) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
savedSuppliersWithRates =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
234
|
+
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing, loadingCart }, getters: { needToPickup }, commit }, { shop, country, currency }) {
|
|
235
|
+
if (!loadingCart) {
|
|
236
|
+
console.trace();
|
|
237
|
+
let savedSuppliersWithRates = null;
|
|
238
|
+
try {
|
|
239
|
+
savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
|
|
240
|
+
} catch (e) {}
|
|
241
|
+
const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates || savedSuppliersWithRates;
|
|
242
|
+
const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
|
|
243
|
+
console.log('calculateCartPrice:payload: ', payload)
|
|
244
|
+
try {
|
|
245
|
+
commit('setCartPricingCalculating', true);
|
|
246
|
+
const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
|
|
247
|
+
commit('setCartPricing', response);
|
|
248
|
+
commit('setCartPricingError', null);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
const { error = 'Error calculate pricing' } = e.response?.data || {};
|
|
251
|
+
commit('setCartPricingError', error);
|
|
252
|
+
commit('setCartPricing', null);
|
|
253
|
+
} finally {
|
|
254
|
+
commit('setCartPricingCalculating', false);
|
|
255
|
+
}
|
|
251
256
|
}
|
|
252
257
|
},
|
|
253
258
|
async setSimpleProductAmount({ state, commit }, { guid, amount, shop, currency }) {
|
|
@@ -310,6 +315,10 @@ export const actions = {
|
|
|
310
315
|
};
|
|
311
316
|
|
|
312
317
|
export const mutations = {
|
|
318
|
+
setLoadingCart(state, loadingCart) {
|
|
319
|
+
state.loadingCart = loadingCart;
|
|
320
|
+
console.log('state.loadingCart: ', state.loadingCart);
|
|
321
|
+
},
|
|
313
322
|
setCart(state, cart) {
|
|
314
323
|
state.id = cart?._id;
|
|
315
324
|
state.entities = cart?.entities || [];
|
package/store/index.js
CHANGED
|
@@ -5,7 +5,18 @@ import { getShopCountrySettings } from '@lancom/shared/assets/js/utils/shop';
|
|
|
5
5
|
import { MESSAGES, COUNTRIES_MESSAGES } from '@/messages';
|
|
6
6
|
import { SETTINGS, COUNTRIES_SETTINGS } from '@/settings';
|
|
7
7
|
const cookieparser = process.server ? require('cookieparser') : undefined;
|
|
8
|
+
const Cookies = process.browser ? require('js-cookie') : undefined;
|
|
8
9
|
const CLOSED_NOTIFICATION = 'lancom-closed-notification-1.0';
|
|
10
|
+
const GCLID_COOKIE = 'gclid';
|
|
11
|
+
const GCLID_EXPIRE_DAYS = 90;
|
|
12
|
+
|
|
13
|
+
function getGclidCookie() {
|
|
14
|
+
return Cookies?.get(GCLID_COOKIE) || null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function setGclidCookie(value) {
|
|
18
|
+
Cookies?.set(GCLID_COOKIE, value, { expires: GCLID_EXPIRE_DAYS, path: '/' });
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
export const state = () => ({
|
|
11
22
|
googleClickId: null,
|
|
@@ -108,6 +119,7 @@ export const actions = {
|
|
|
108
119
|
}
|
|
109
120
|
},
|
|
110
121
|
async loadState({ dispatch, commit, state: { shop, currency, country, notificationBar } }, query) {
|
|
122
|
+
console.log('loadState...', query);
|
|
111
123
|
const state = await loadState(query);
|
|
112
124
|
if (state) {
|
|
113
125
|
commit('setState', state);
|
|
@@ -116,19 +128,31 @@ export const actions = {
|
|
|
116
128
|
currency: currency?._id,
|
|
117
129
|
country: country?._id
|
|
118
130
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
commit('cart/setLoadingCart', true);
|
|
132
|
+
try {
|
|
133
|
+
const cart = await api.fetchCartById(shop._id, state.cart?.id, params);
|
|
134
|
+
commit('cart/setCart', cart);
|
|
135
|
+
if (state.cart?.coupon) {
|
|
136
|
+
try {
|
|
137
|
+
const code = state.cart?.coupon.code || state.cart?.coupon;
|
|
138
|
+
const coupon = await api.fetchCouponByCode(shop._id, code);
|
|
139
|
+
commit('cart/setCoupon', coupon);
|
|
140
|
+
} catch (e) {}
|
|
141
|
+
}
|
|
142
|
+
dispatch('cart/calculateCartPrice', { shop, country });
|
|
143
|
+
} catch (e) {
|
|
144
|
+
} finally {
|
|
145
|
+
commit('cart/setLoadingCart', false);
|
|
127
146
|
}
|
|
128
|
-
dispatch('cart/calculateCartPrice', { shop, country });
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
|
-
|
|
149
|
+
|
|
150
|
+
const cookieGclid = getGclidCookie();
|
|
151
|
+
const googleClickId = query.gclid || cookieGclid || null;
|
|
152
|
+
commit('setGoogleClickId', googleClickId);
|
|
153
|
+
if (query.gclid) {
|
|
154
|
+
setGclidCookie(query.gclid);
|
|
155
|
+
}
|
|
132
156
|
|
|
133
157
|
const closedNotification = localStorage.getItem(CLOSED_NOTIFICATION);
|
|
134
158
|
if (notificationBar?.text === closedNotification) {
|