@lancom/shared 0.0.376 → 0.0.377
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/utils/quote.js
CHANGED
|
@@ -3,6 +3,7 @@ import { populatePrints } from './order';
|
|
|
3
3
|
export function convertQuoteToOrder(quote, option) {
|
|
4
4
|
const files = [quote.file, ...(quote.files || [])].filter(f => !!f);
|
|
5
5
|
return {
|
|
6
|
+
purchaseOrderNumber: quote.purchaseOrderNumber,
|
|
6
7
|
isUrgent: quote.isUrgent,
|
|
7
8
|
deliveryBy: quote.deliveryBy,
|
|
8
9
|
deliveryAfter: quote.deliveryAfter,
|
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
&__postcode-container {
|
|
8
8
|
margin-top: 22px;
|
|
9
9
|
}
|
|
10
|
+
&__pickup-label {
|
|
11
|
+
font-weight: 800;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
line-height: 22px;
|
|
14
|
+
text-transform: uppercase;
|
|
15
|
+
color: #303030;
|
|
16
|
+
}
|
|
17
|
+
&__pickup-errors {
|
|
18
|
+
color: $error;
|
|
19
|
+
font-size: 13px;
|
|
20
|
+
}
|
|
10
21
|
// &__total-info {
|
|
11
22
|
// position: sticky;
|
|
12
23
|
// top: 130px;
|
|
@@ -31,6 +31,25 @@
|
|
|
31
31
|
:label-text="postcodeInfoLabel"
|
|
32
32
|
@select="handleSuburbChange" />
|
|
33
33
|
</div>
|
|
34
|
+
<div>
|
|
35
|
+
<div class="mt-20 mb-20">
|
|
36
|
+
<checkbox
|
|
37
|
+
v-model="wantsToPickup"
|
|
38
|
+
:disabled="hasNotValidProductsPickup"
|
|
39
|
+
:dark="true">
|
|
40
|
+
<div class="ml-10 Cart__pickup-label">Wants to pickup</div>
|
|
41
|
+
</checkbox>
|
|
42
|
+
</div>
|
|
43
|
+
<div v-if="hasNotValidProductsPickup">
|
|
44
|
+
<ul class="Cart__pickup-errors">
|
|
45
|
+
<li
|
|
46
|
+
v-for="product in notValidProductsPickup"
|
|
47
|
+
:key="product._id">
|
|
48
|
+
Not Available for pickup <b>{{ product.name }}. {{ product.size ? product.size.shortName : '' }}</b> order quantity: {{ product.amount }}. Available {{ product.warehouseQuantityStock }}
|
|
49
|
+
</li>
|
|
50
|
+
</ul>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
34
53
|
<div class="Cart__coupon-container">
|
|
35
54
|
<coupon-select
|
|
36
55
|
v-model="cartCoupon"
|
|
@@ -44,7 +63,7 @@
|
|
|
44
63
|
<btn
|
|
45
64
|
:btn-disabled="isNotValidQuantity || cartPricingError || cartPricingCalculating"
|
|
46
65
|
:btn-block="true"
|
|
47
|
-
to="/checkout/order"
|
|
66
|
+
:to="needToPickup ? `/checkout/order?needToPickup=true` : '/checkout/order'"
|
|
48
67
|
btn-class="green"
|
|
49
68
|
btn-label="PROCEED TO CHECKOUT">
|
|
50
69
|
<i
|
|
@@ -71,7 +90,7 @@
|
|
|
71
90
|
</template>
|
|
72
91
|
|
|
73
92
|
<script>
|
|
74
|
-
import { mapGetters } from 'vuex';
|
|
93
|
+
import { mapGetters, mapMutations } from 'vuex';
|
|
75
94
|
import gtm from '@lancom/shared/assets/js/utils/gtm';
|
|
76
95
|
import PostcodeSelect from '@lancom/shared/components/common/postcode_select/postcode-select';
|
|
77
96
|
import CouponSelect from '@lancom/shared/components/common/coupon_select/coupon-select';
|
|
@@ -80,6 +99,7 @@ import CartEntity from '@lancom/shared/components/checkout/cart/cart_entity/cart
|
|
|
80
99
|
import { price } from '@lancom/shared/assets/js/utils/filters';
|
|
81
100
|
import CartMixin from '@lancom/shared/components/checkout/cart/cart.mixin';
|
|
82
101
|
import CartPriceInfo from '@lancom/shared/components/checkout/cart/cart_price_info/cart-price-info';
|
|
102
|
+
|
|
83
103
|
export default {
|
|
84
104
|
name: 'CheckoutCart',
|
|
85
105
|
components: {
|
|
@@ -93,7 +113,18 @@ export default {
|
|
|
93
113
|
mixins: [CartMixin],
|
|
94
114
|
computed: {
|
|
95
115
|
...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
|
|
96
|
-
...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities']),
|
|
116
|
+
...mapGetters('cart', ['isEmpty', 'needToPickup', 'notValidProductsPickup','cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities']),
|
|
117
|
+
wantsToPickup: {
|
|
118
|
+
get() {
|
|
119
|
+
return this.needToPickup;
|
|
120
|
+
},
|
|
121
|
+
set(needToPickup) {
|
|
122
|
+
this.setNeedToPickup(needToPickup);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
hasNotValidProductsPickup() {
|
|
126
|
+
return this.notValidProductsPickup.length > 0;
|
|
127
|
+
},
|
|
97
128
|
onlyPostcode() {
|
|
98
129
|
return !!this.SETTINGS.CART_ONLY_POSTCODE && this.country?.isoCode === 'UK';
|
|
99
130
|
},
|
|
@@ -117,6 +148,7 @@ export default {
|
|
|
117
148
|
}
|
|
118
149
|
},
|
|
119
150
|
methods: {
|
|
151
|
+
...mapMutations('cart', ['setNeedToPickup']),
|
|
120
152
|
loadedPricing() {
|
|
121
153
|
gtm.viewCart(this.entities, this.cartPricing, this.currency);
|
|
122
154
|
}
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -4,9 +4,12 @@ import gtm from '@lancom/shared/assets/js/utils/gtm';
|
|
|
4
4
|
import { getPrintTypeSizePricing } from '@lancom/shared/assets/js/utils/prints';
|
|
5
5
|
import { filterBigSize } from '@lancom/shared/assets/js/utils/product';
|
|
6
6
|
|
|
7
|
+
const SUPPLIERS_WITH_RATES_KEY = 'suppliers-with-wates';
|
|
8
|
+
|
|
7
9
|
export const state = () => ({
|
|
8
10
|
id: null,
|
|
9
11
|
entities: [],
|
|
12
|
+
needToPickup: false,
|
|
10
13
|
suburb: null,
|
|
11
14
|
coupon: null,
|
|
12
15
|
cartPricingCalculating: false,
|
|
@@ -26,12 +29,21 @@ const getProductsQuantities = entities => {
|
|
|
26
29
|
const grouped = groupBy(entities, e => e.product._id);
|
|
27
30
|
const quantities = Object.keys(grouped).map(_id => {
|
|
28
31
|
const [{ prints, product: { name, minimumOrderQuantity, minimumPrintOrderQuantity } }] = grouped[_id];
|
|
29
|
-
console.log('');
|
|
30
|
-
console.log('getProductsQuantities:', prints);
|
|
31
|
-
console.log('minimumPrintOrderQuantity: ', minimumPrintOrderQuantity);
|
|
32
|
-
console.log('minimumOrderQuantity: ', minimumOrderQuantity);
|
|
33
32
|
const minQty = (prints?.length > 0 ? minimumPrintOrderQuantity : minimumOrderQuantity) || minimumOrderQuantity;
|
|
34
|
-
|
|
33
|
+
const simpleProducts = grouped[_id].reduce((simpleProducts, product) => {
|
|
34
|
+
product.simpleProducts?.forEach(simpleProduct => {
|
|
35
|
+
if (simpleProduct.amount > 0) {
|
|
36
|
+
let existSimpleProduct = simpleProducts.find(sp => sp.SKU === simpleProduct.SKU);
|
|
37
|
+
if (!existSimpleProduct) {
|
|
38
|
+
existSimpleProduct = { ...simpleProduct, amount: 0 };
|
|
39
|
+
simpleProducts.push(existSimpleProduct);
|
|
40
|
+
}
|
|
41
|
+
existSimpleProduct.amount += simpleProduct.amount;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return simpleProducts;
|
|
45
|
+
}, []);
|
|
46
|
+
return { _id, name, minimumOrderQuantity: minQty, quantity: getEntitiesQuantity(grouped[_id]), simpleProducts };
|
|
35
47
|
});
|
|
36
48
|
return quantities;
|
|
37
49
|
};
|
|
@@ -63,6 +75,7 @@ const getPrintsQuantities = entities => {
|
|
|
63
75
|
export const getters = {
|
|
64
76
|
entities: ({ entities }) => entities,
|
|
65
77
|
coupon: ({ coupon }) => coupon,
|
|
78
|
+
needToPickup: ({ needToPickup }) => needToPickup,
|
|
66
79
|
cartPricingCalculating: ({ cartPricingCalculating }) => cartPricingCalculating,
|
|
67
80
|
simpleProducts: ({ entities }) => entities.reduce((simpleProducts, entity) => [...simpleProducts, ...(entity.simpleProducts || [])], []),
|
|
68
81
|
notEmptySimpleProducts: (state, { simpleProducts }) => simpleProducts.filter(e => e.amount > 0),
|
|
@@ -80,6 +93,23 @@ export const getters = {
|
|
|
80
93
|
notValidProductsQuantities(state, { quantities }) {
|
|
81
94
|
return (quantities?.products || []).filter(({ minimumOrderQuantity, quantity }) => quantity < minimumOrderQuantity);
|
|
82
95
|
},
|
|
96
|
+
notValidProductsPickup(state, { quantities }) {
|
|
97
|
+
const simpleProducts = (quantities?.products || [])
|
|
98
|
+
.reduce((simpleProducts, product) => {
|
|
99
|
+
return [
|
|
100
|
+
...simpleProducts,
|
|
101
|
+
...product?.simpleProducts?.map(sp => ({
|
|
102
|
+
name: product.name,
|
|
103
|
+
...sp
|
|
104
|
+
}))
|
|
105
|
+
]
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
const notValid = simpleProducts.filter(sp => sp.warehouseQuantityStock < sp.amount)
|
|
109
|
+
|
|
110
|
+
return notValid;
|
|
111
|
+
|
|
112
|
+
},
|
|
83
113
|
notValidStockQuantities(state, { quantities }) {
|
|
84
114
|
return (quantities?.stock || []).filter(({ maxQuantity, quantity }) => quantity > maxQuantity);
|
|
85
115
|
},
|
|
@@ -159,13 +189,17 @@ export const actions = {
|
|
|
159
189
|
await api.saveCart(payload, shop._id);
|
|
160
190
|
commit('setEntities', entities);
|
|
161
191
|
},
|
|
162
|
-
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, commit }, { shop, country, currency }) {
|
|
163
|
-
|
|
192
|
+
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing, needToPickup }, commit }, { shop, country, currency }) {
|
|
193
|
+
let savedSuppliersWithRates = null;
|
|
194
|
+
try {
|
|
195
|
+
savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
|
|
196
|
+
} catch (e) {}
|
|
197
|
+
const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates || savedSuppliersWithRates;
|
|
164
198
|
const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
|
|
165
199
|
console.log('calculateCartPrice:payload: ', payload)
|
|
166
200
|
try {
|
|
167
201
|
commit('setCartPricingCalculating', true);
|
|
168
|
-
const response = await api.calculateProductPrice(payload, shop._id);
|
|
202
|
+
const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
|
|
169
203
|
commit('setCartPricing', response);
|
|
170
204
|
commit('setCartPricingError', null);
|
|
171
205
|
} catch (e) {
|
|
@@ -202,6 +236,10 @@ export const actions = {
|
|
|
202
236
|
})
|
|
203
237
|
: supplierWithRates)
|
|
204
238
|
}));
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
localStorage.setItem(SUPPLIERS_WITH_RATES_KEY, JSON.stringify(suppliersWithRates));
|
|
242
|
+
} catch (e) {}
|
|
205
243
|
const payload = generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, null, country, currency);
|
|
206
244
|
try {
|
|
207
245
|
commit('setCartPricingCalculating', true);
|
|
@@ -226,6 +264,9 @@ export const mutations = {
|
|
|
226
264
|
setId(state, id) {
|
|
227
265
|
state.id = id;
|
|
228
266
|
},
|
|
267
|
+
setNeedToPickup(state, needToPickup) {
|
|
268
|
+
state.needToPickup = needToPickup;
|
|
269
|
+
},
|
|
229
270
|
setEntities(state, entities) {
|
|
230
271
|
console.log('setEntities: ', entities);
|
|
231
272
|
state.entities = entities;
|
|
@@ -255,6 +296,7 @@ export const mutations = {
|
|
|
255
296
|
state.suburb = null;
|
|
256
297
|
state.coupon = null;
|
|
257
298
|
state.cartPricingError = null;
|
|
299
|
+
localStorage.removeItem(SUPPLIERS_WITH_RATES_KEY);
|
|
258
300
|
}
|
|
259
301
|
};
|
|
260
302
|
|
package/store/index.js
CHANGED
|
@@ -53,7 +53,7 @@ export const getters = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
export const actions = {
|
|
56
|
-
async nuxtServerInit({ commit }, { req }) {
|
|
56
|
+
async nuxtServerInit({ commit }, { req, query }) {
|
|
57
57
|
const shop = await api.fetchShopByUrl(process.env.HOST_NAME);
|
|
58
58
|
const menus = await api.fetchMenus(shop._id);
|
|
59
59
|
commit('setMenus', menus);
|
|
@@ -98,6 +98,10 @@ export const actions = {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
} catch (e) {}
|
|
101
|
+
|
|
102
|
+
if (query?.needToPickup === 'true') {
|
|
103
|
+
commit('cart/setNeedToPickup', true);
|
|
104
|
+
}
|
|
101
105
|
},
|
|
102
106
|
async loadState({ dispatch, commit, state: { shop, currency, country, notificationBar } }, query) {
|
|
103
107
|
const state = await loadState();
|