@lancom/shared 0.0.269 → 0.0.270
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/components/product/product_multipacks_carousel/product-multipacks-carousel.vue +54 -10
- package/components/product/product_multipacks_carousel/product_multipack/product-multipack.scss +9 -1
- package/components/product/product_multipacks_carousel/product_multipack/product-multipack.vue +30 -7
- package/feeds/google-shopping.js +1 -1
- package/package.json +1 -1
- package/store/product.js +5 -0
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
'ProductMultipacksCarousel__item--active': multipack === selectedMultipack
|
|
10
10
|
}">
|
|
11
11
|
<product-multipack
|
|
12
|
+
:color="color"
|
|
12
13
|
:multipack="multipack"
|
|
13
14
|
:simple-products="simpleProducts"
|
|
15
|
+
:active="multipack === selectedMultipack"
|
|
16
|
+
:with-gst="withGst"
|
|
14
17
|
class="elevation2"
|
|
15
18
|
@selected="toggleMultipack(multipack)" />
|
|
16
19
|
</div>
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
</template>
|
|
32
35
|
|
|
33
36
|
<script>
|
|
34
|
-
import { mapMutations } from 'vuex';
|
|
37
|
+
import { mapMutations, mapGetters } from 'vuex';
|
|
35
38
|
import { inRange } from '@lancom/shared/assets/js/utils/filters';
|
|
36
39
|
import ProductMultipack from './product_multipack/product-multipack';
|
|
37
40
|
|
|
@@ -42,25 +45,44 @@ export default {
|
|
|
42
45
|
},
|
|
43
46
|
data() {
|
|
44
47
|
return {
|
|
45
|
-
thumbsPage: 0
|
|
46
|
-
selectedMultipack: null
|
|
48
|
+
thumbsPage: 0
|
|
47
49
|
};
|
|
48
50
|
},
|
|
49
51
|
props: {
|
|
50
52
|
product: {
|
|
51
|
-
type:
|
|
53
|
+
type: Object,
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
color: {
|
|
57
|
+
type: Object,
|
|
52
58
|
required: true
|
|
53
59
|
},
|
|
54
60
|
simpleProducts: {
|
|
55
61
|
type: Array,
|
|
56
62
|
required: true
|
|
57
63
|
},
|
|
64
|
+
withGst: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
58
68
|
slidesPerRow: {
|
|
59
69
|
type: Number,
|
|
60
70
|
default: 3
|
|
61
71
|
}
|
|
62
72
|
},
|
|
73
|
+
created() {
|
|
74
|
+
console.log('LancomProductMultipacks...')
|
|
75
|
+
},
|
|
63
76
|
computed: {
|
|
77
|
+
...mapGetters('product', ['multipack']),
|
|
78
|
+
selectedMultipack: {
|
|
79
|
+
get() {
|
|
80
|
+
return this.multipack;
|
|
81
|
+
},
|
|
82
|
+
set(multipack) {
|
|
83
|
+
this.setMultipack(multipack);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
64
86
|
multipacks() {
|
|
65
87
|
return this.product.multipacks || [];
|
|
66
88
|
},
|
|
@@ -72,6 +94,7 @@ export default {
|
|
|
72
94
|
}
|
|
73
95
|
},
|
|
74
96
|
methods: {
|
|
97
|
+
...mapMutations('product', ['setSimpleProductAmount', 'clearSimpleProductsAmount', 'setMultipack']),
|
|
75
98
|
toggleMultipack(multipack) {
|
|
76
99
|
this.selectedMultipack = this.selectedMultipack === multipack ? null : multipack;
|
|
77
100
|
this.clearSimpleProductsAmount();
|
|
@@ -79,21 +102,42 @@ export default {
|
|
|
79
102
|
this.buyMultipack()
|
|
80
103
|
}
|
|
81
104
|
},
|
|
82
|
-
...mapMutations('product', ['setSimpleProductAmount', 'clearSimpleProductsAmount']),
|
|
83
105
|
buyMultipack() {
|
|
84
|
-
const
|
|
106
|
+
const leftQty = this.addSimpleProducts([
|
|
85
107
|
{ size: 'S', percent: 0.15 },
|
|
86
108
|
{ size: 'M', percent: 0.2 },
|
|
87
109
|
{ size: 'XL', percent: 0.3 },
|
|
88
110
|
{ size: '2XL', percent: 0.05 },
|
|
89
111
|
{ size: 'L' }
|
|
90
|
-
];
|
|
112
|
+
]);
|
|
113
|
+
if (leftQty > 0) {
|
|
114
|
+
this.clearSimpleProductsAmount();
|
|
115
|
+
const sizes = [
|
|
116
|
+
{ size: 'L' },
|
|
117
|
+
{ size: 'XL' },
|
|
118
|
+
{ size: 'M' },
|
|
119
|
+
...this.simpleProducts
|
|
120
|
+
.filter(sp => sp.color?._id === this.color._id)
|
|
121
|
+
.filter(simpleProduct => !['L','XL','M'].includes(simpleProduct.size?.shortName))
|
|
122
|
+
.map(simpleProduct => ({ size: simpleProduct.size?.shortName }))
|
|
123
|
+
];
|
|
124
|
+
const repeatLeftQty = this.addSimpleProducts(sizes);
|
|
125
|
+
if (repeatLeftQty > 0) {
|
|
126
|
+
this.selectedMultipack = null;
|
|
127
|
+
this.clearSimpleProductsAmount();
|
|
128
|
+
this.$toastr.e('Stock unavailable');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
addSimpleProducts(sizes) {
|
|
91
133
|
let leftQty = this.selectedMultipack.qty;
|
|
92
134
|
sizes.forEach(s => {
|
|
93
|
-
const simpleProduct = this.simpleProducts
|
|
135
|
+
const simpleProduct = this.simpleProducts
|
|
136
|
+
.filter(sp => sp.color?._id === this.color._id)
|
|
137
|
+
.find(simpleProduct => simpleProduct.size?.shortName === s.size);
|
|
94
138
|
if (simpleProduct) {
|
|
95
139
|
const qty = s.percent ? +(s.percent * this.selectedMultipack.qty).toFixed(0) : leftQty;
|
|
96
|
-
const amount = inRange(qty, 0, simpleProduct.quantityStock ||
|
|
140
|
+
const amount = inRange(qty, 0, simpleProduct.quantityStock || 0);
|
|
97
141
|
leftQty -= amount;
|
|
98
142
|
this.setSimpleProductAmount({
|
|
99
143
|
colorId: simpleProduct.color._id,
|
|
@@ -102,7 +146,7 @@ export default {
|
|
|
102
146
|
});
|
|
103
147
|
}
|
|
104
148
|
});
|
|
105
|
-
|
|
149
|
+
return leftQty;
|
|
106
150
|
},
|
|
107
151
|
goToPrevPage() {
|
|
108
152
|
this.thumbsPage = Math.max(0, this.thumbsPage - 1);
|
package/components/product/product_multipacks_carousel/product_multipack/product-multipack.scss
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
@import "@/assets/scss/variables";
|
|
2
2
|
|
|
3
3
|
.ProductMultipack {
|
|
4
|
+
&__wrapper {
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
}
|
|
4
7
|
&__price {
|
|
5
8
|
padding: 10px;
|
|
6
9
|
text-align: center;
|
|
@@ -34,10 +37,15 @@
|
|
|
34
37
|
&-info {
|
|
35
38
|
position: absolute;
|
|
36
39
|
top: 0px;
|
|
37
|
-
|
|
40
|
+
left: 0px;
|
|
38
41
|
display: flex;
|
|
39
42
|
flex-direction: column;
|
|
40
43
|
align-items: end;
|
|
41
44
|
}
|
|
45
|
+
&-active {
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 7px;
|
|
48
|
+
right: 7px;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
}
|
package/components/product/product_multipacks_carousel/product_multipack/product-multipack.vue
CHANGED
|
@@ -20,47 +20,70 @@
|
|
|
20
20
|
@onclick="buyMultipack()" />
|
|
21
21
|
</div>
|
|
22
22
|
</div>
|
|
23
|
+
<div class="ProductMultipack__banner-active">
|
|
24
|
+
<checked-icon :checked="active" />
|
|
25
|
+
</div>
|
|
23
26
|
</div>
|
|
24
27
|
<div class="ProductMultipack__price">
|
|
25
|
-
{{ oneItemPrice |
|
|
26
|
-
<span>{{ totalPrice |
|
|
28
|
+
{{ oneItemPrice | price(currency) }} each
|
|
29
|
+
<span>{{ totalPrice | price(currency) }}</span>
|
|
27
30
|
</div>
|
|
28
31
|
</div>
|
|
29
32
|
</template>
|
|
30
33
|
|
|
31
34
|
<script>
|
|
32
35
|
import { mapGetters } from 'vuex';
|
|
33
|
-
import {
|
|
36
|
+
import { price, tax } from '@lancom/shared/assets/js/utils/filters';
|
|
37
|
+
import CheckedIcon from '@lancom/shared/components/common/checked-icon';
|
|
38
|
+
import { priceFromRange } from '@lancom/shared/assets/js/utils/pricing';
|
|
34
39
|
|
|
35
40
|
export default {
|
|
36
41
|
name: 'LancomProductMultipack',
|
|
42
|
+
components: {
|
|
43
|
+
CheckedIcon
|
|
44
|
+
},
|
|
37
45
|
filters: {
|
|
38
|
-
|
|
46
|
+
price
|
|
39
47
|
},
|
|
40
48
|
props: {
|
|
49
|
+
color: {
|
|
50
|
+
type: Object,
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
41
53
|
multipack: {
|
|
42
54
|
type: Object,
|
|
43
55
|
required: true
|
|
44
56
|
},
|
|
57
|
+
withGst: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
active: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
45
65
|
simpleProducts: {
|
|
46
66
|
type: Array,
|
|
47
67
|
required: true
|
|
48
68
|
}
|
|
49
69
|
},
|
|
50
70
|
computed: {
|
|
51
|
-
...mapGetters(['pricingSettings', 'currency']),
|
|
71
|
+
...mapGetters(['pricingSettings', 'currency', 'gstTax']),
|
|
52
72
|
bannerImage() {
|
|
53
73
|
const banner = this.multipack.banner?.editorImage || this.multipack.banner;
|
|
54
74
|
return banner?.origin;
|
|
55
75
|
},
|
|
56
76
|
simpleProduct() {
|
|
57
|
-
|
|
77
|
+
const simpleProduct = (this.simpleProducts || []).find(sp => sp.SKU === this.multipack.SKU);
|
|
78
|
+
const simpleProducts = (this.simpleProducts || []).filter(sp => sp.color?._id === this.color._id);
|
|
79
|
+
return simpleProducts.find(sp => sp.size?.shortName === simpleProduct?.size?.shortName) || simpleProducts[0];
|
|
58
80
|
},
|
|
59
81
|
totalPrice() {
|
|
60
82
|
return this.oneItemPrice * this.multipack.qty;
|
|
61
83
|
},
|
|
62
84
|
oneItemPrice() {
|
|
63
|
-
|
|
85
|
+
const price = priceFromRange(this.multipack.qty, this.simpleProduct?.pricing);
|
|
86
|
+
return this.withGst ? tax(price, this.gstTax) : price;
|
|
64
87
|
}
|
|
65
88
|
},
|
|
66
89
|
methods: {
|
package/feeds/google-shopping.js
CHANGED
|
@@ -92,7 +92,7 @@ async function googleShoppingFeed(axios, config, availableStores) {
|
|
|
92
92
|
}
|
|
93
93
|
} else {
|
|
94
94
|
info['g:pickup_method'] = { _text: 'not_supported' };
|
|
95
|
-
info['g:excluded_destination'] = { _text: 'Local_inventory_ads' };
|
|
95
|
+
info['g:excluded_destination'] = [{ _text: 'Local_inventory_ads' }, { _text: 'Free_local_listings' }];
|
|
96
96
|
}
|
|
97
97
|
if (product.volume) {
|
|
98
98
|
if (product.volume.length) {
|
package/package.json
CHANGED
package/store/product.js
CHANGED
|
@@ -10,6 +10,7 @@ import { filterBigSize } from '@lancom/shared/assets/js/utils/product';
|
|
|
10
10
|
import { sortByName } from '../assets/js/utils/filters';
|
|
11
11
|
|
|
12
12
|
export const state = () => ({
|
|
13
|
+
multipack: null,
|
|
13
14
|
calculatingPrice: false,
|
|
14
15
|
images: [],
|
|
15
16
|
priceIncludeGST: false,
|
|
@@ -45,6 +46,7 @@ export const state = () => ({
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
export const getters = {
|
|
49
|
+
multipack: ({ multipack }) => multipack,
|
|
48
50
|
calculatingPrice: ({ calculatingPrice }) => calculatingPrice,
|
|
49
51
|
product: ({ product }) => product,
|
|
50
52
|
preSetPrint: ({ preSetPrint }) => preSetPrint,
|
|
@@ -263,6 +265,9 @@ export const actions = {
|
|
|
263
265
|
};
|
|
264
266
|
|
|
265
267
|
export const mutations = {
|
|
268
|
+
setMultipack(state, multipack) {
|
|
269
|
+
state.multipack = multipack;
|
|
270
|
+
},
|
|
266
271
|
setProduct(state, product) {
|
|
267
272
|
state.product = product;
|
|
268
273
|
},
|