@lancom/shared 0.0.382 → 0.0.383
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/checkout/cart/cart.mixin.js +3 -12
- package/components/checkout/cart/cart.vue +1 -24
- package/components/checkout/cart/cart_price_info/cart-price-info.scss +11 -0
- package/components/checkout/cart/cart_price_info/cart-price-info.vue +53 -3
- package/components/checkout/cart/cart_shipments_pricing/cart-shipments-pricing.vue +1 -1
- package/components/checkout/order/order-billing-information/order-billing-information.vue +5 -5
- package/package.json +1 -1
- package/store/cart.js +3 -2
|
@@ -8,6 +8,7 @@ export default {
|
|
|
8
8
|
],
|
|
9
9
|
data() {
|
|
10
10
|
return {
|
|
11
|
+
visiblePickupError: false,
|
|
11
12
|
calculateCartPriceWithDebounce: debounce(this.calculateCartPrice, 300)
|
|
12
13
|
};
|
|
13
14
|
},
|
|
@@ -16,6 +17,7 @@ export default {
|
|
|
16
17
|
...mapGetters('auth', ['user']),
|
|
17
18
|
...mapGetters('cart', [
|
|
18
19
|
'needToPickup',
|
|
20
|
+
'needToPickupWithoutErrors',
|
|
19
21
|
'entities',
|
|
20
22
|
'cartPricing',
|
|
21
23
|
'simpleProducts',
|
|
@@ -28,17 +30,6 @@ export default {
|
|
|
28
30
|
'notValidStockQuantities',
|
|
29
31
|
'notValidPrintsQuantities'
|
|
30
32
|
]),
|
|
31
|
-
wantsToPickup: {
|
|
32
|
-
get() {
|
|
33
|
-
return this.needToPickup;
|
|
34
|
-
},
|
|
35
|
-
set(needToPickup) {
|
|
36
|
-
if (needToPickup) {
|
|
37
|
-
this.setSuburb(null);
|
|
38
|
-
}
|
|
39
|
-
this.setNeedToPickup(needToPickup);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
33
|
isNotValidQuantity() {
|
|
43
34
|
return this.isNotValidProductsQuantity || this.isNotValidStockQuantity || this.isNotValidPrintsQuantity || this.isNotValidPrintsBigSizeQuantity;
|
|
44
35
|
},
|
|
@@ -81,7 +72,7 @@ export default {
|
|
|
81
72
|
},
|
|
82
73
|
handleSuburbChange(suburb) {
|
|
83
74
|
this.setSuburb(suburb);
|
|
84
|
-
this.setNeedToPickup(false);
|
|
75
|
+
// this.setNeedToPickup(false);
|
|
85
76
|
this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
|
|
86
77
|
},
|
|
87
78
|
handleCouponChange(coupon) {
|
|
@@ -31,26 +31,6 @@
|
|
|
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
|
-
@change="recalculatePricing()">
|
|
41
|
-
<div class="ml-10 Cart__pickup-label">Wants to pickup</div>
|
|
42
|
-
</checkbox>
|
|
43
|
-
</div>
|
|
44
|
-
<div v-if="hasNotValidProductsPickup">
|
|
45
|
-
<ul class="Cart__pickup-errors">
|
|
46
|
-
<li
|
|
47
|
-
v-for="product in notValidProductsPickup"
|
|
48
|
-
:key="product._id">
|
|
49
|
-
Not Available for pickup <b>{{ product.name }}. {{ product.size ? product.size.shortName : '' }}</b> order quantity: {{ product.amount }}. Available {{ product.warehouseQuantityStock }}
|
|
50
|
-
</li>
|
|
51
|
-
</ul>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
34
|
<div class="Cart__coupon-container">
|
|
55
35
|
<coupon-select
|
|
56
36
|
v-model="cartCoupon"
|
|
@@ -114,10 +94,7 @@ export default {
|
|
|
114
94
|
mixins: [CartMixin],
|
|
115
95
|
computed: {
|
|
116
96
|
...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
|
|
117
|
-
...mapGetters('cart', ['isEmpty',
|
|
118
|
-
hasNotValidProductsPickup() {
|
|
119
|
-
return this.notValidProductsPickup.length > 0;
|
|
120
|
-
},
|
|
97
|
+
...mapGetters('cart', ['isEmpty','cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities']),
|
|
121
98
|
onlyPostcode() {
|
|
122
99
|
return !!this.SETTINGS.CART_ONLY_POSTCODE && this.country?.isoCode === 'UK';
|
|
123
100
|
},
|
|
@@ -7,4 +7,15 @@
|
|
|
7
7
|
color: $white;
|
|
8
8
|
background-color: $error;
|
|
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
|
}
|
|
@@ -10,6 +10,30 @@
|
|
|
10
10
|
class="CartPriceInfo__error">
|
|
11
11
|
{{ cartPricingError }}
|
|
12
12
|
</div>
|
|
13
|
+
<div>
|
|
14
|
+
<div class="mt-20 mb-20">
|
|
15
|
+
<checkbox
|
|
16
|
+
v-model="wantsToPickup"
|
|
17
|
+
:dark="true"
|
|
18
|
+
@change="calculatePrice()">
|
|
19
|
+
<div class="ml-10 CartPriceInfo__pickup-label">
|
|
20
|
+
{{ contacts.warehousePickupInfo ? `Pickup from ${contacts.warehousePickupInfo}` : 'Wants to pickup' }}
|
|
21
|
+
</div>
|
|
22
|
+
</checkbox>
|
|
23
|
+
</div>
|
|
24
|
+
<div
|
|
25
|
+
v-if="hasNotValidProductsPickup"
|
|
26
|
+
class="CartPriceInfo__pickup-errors">
|
|
27
|
+
<div>Not all items in cart are available for pickup. Some items are available for delivery only</div>
|
|
28
|
+
<ul>
|
|
29
|
+
<li
|
|
30
|
+
v-for="product in notValidProductsPickup"
|
|
31
|
+
:key="product._id">
|
|
32
|
+
<b>{{ product.name }}. {{ product.size ? product.size.shortName : '' }}</b> order quantity: {{ product.amount }}. Available {{ product.warehouseQuantityStock }}
|
|
33
|
+
</li>
|
|
34
|
+
</ul>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
13
37
|
</div>
|
|
14
38
|
</template>
|
|
15
39
|
|
|
@@ -19,7 +43,7 @@ import debounce from 'lodash.debounce';
|
|
|
19
43
|
import CartPricing from '@lancom/shared/components/checkout/cart/cart_pricing/cart-pricing';
|
|
20
44
|
import { price } from '@lancom/shared/assets/js/utils/filters';
|
|
21
45
|
|
|
22
|
-
const { mapActions } = createNamespacedHelpers('cart');
|
|
46
|
+
const { mapActions, mapMutations } = createNamespacedHelpers('cart');
|
|
23
47
|
|
|
24
48
|
export default {
|
|
25
49
|
name: 'LancomCartPriceInfo',
|
|
@@ -35,17 +59,39 @@ export default {
|
|
|
35
59
|
},
|
|
36
60
|
data() {
|
|
37
61
|
return {
|
|
62
|
+
visiblePickupError: null,
|
|
38
63
|
price: null,
|
|
39
64
|
calculatePriceWithDebounce: debounce(this.calculatePrice, 500)
|
|
40
65
|
};
|
|
41
66
|
},
|
|
42
67
|
computed: {
|
|
43
|
-
...mapGetters(['shop', 'country', 'currency']),
|
|
68
|
+
...mapGetters(['shop', 'country', 'currency', 'contacts']),
|
|
44
69
|
...mapGetters('cart', [
|
|
70
|
+
'notValidProductsPickup',
|
|
71
|
+
'needToPickup',
|
|
72
|
+
'needToPickupWithoutErrors',
|
|
45
73
|
'entities',
|
|
46
74
|
'cartPricing',
|
|
47
75
|
'cartPricingError'
|
|
48
|
-
])
|
|
76
|
+
]),
|
|
77
|
+
hasNotValidProductsPickup() {
|
|
78
|
+
return this.notValidProductsPickup.length > 0;
|
|
79
|
+
},
|
|
80
|
+
wantsToPickup: {
|
|
81
|
+
get() {
|
|
82
|
+
return this.needToPickup;
|
|
83
|
+
},
|
|
84
|
+
set(needToPickup) {
|
|
85
|
+
if (needToPickup && this.hasNotValidProductsPickup) {
|
|
86
|
+
this.visiblePickupError = true;
|
|
87
|
+
} else {
|
|
88
|
+
// if (needToPickup) {
|
|
89
|
+
// this.setSuburb(null);
|
|
90
|
+
// }
|
|
91
|
+
this.setNeedToPickup(needToPickup);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
49
95
|
},
|
|
50
96
|
watch: {
|
|
51
97
|
entities() {
|
|
@@ -57,6 +103,10 @@ export default {
|
|
|
57
103
|
this.$emit('loaded', this.cartPricing);
|
|
58
104
|
},
|
|
59
105
|
methods: {
|
|
106
|
+
...mapMutations([
|
|
107
|
+
'setSuburb',
|
|
108
|
+
'setNeedToPickup'
|
|
109
|
+
]),
|
|
60
110
|
...mapActions([
|
|
61
111
|
'calculateCartPrice'
|
|
62
112
|
]),
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
:class="{
|
|
34
34
|
'CartShipmentsPricing__rate--disabled': rate.disabled
|
|
35
35
|
}"
|
|
36
|
-
@click="selectRate({ supplier, rate, shop, country, currency })">
|
|
36
|
+
@click="!rate.selected && selectRate({ supplier, rate, shop, country, currency })">
|
|
37
37
|
<div class="CartShipmentsPricing__rate-info">
|
|
38
38
|
<div class="CartShipmentsPricing__rate-icon">
|
|
39
39
|
<checked-icon :checked="rate.selected" />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="OrderBillingInformation__wrapper">
|
|
3
3
|
<div class="lc_h3 lc_uppercase lc_bold">
|
|
4
|
-
{{
|
|
4
|
+
{{ needToPickupWithoutErrors ? 'Contact Info' : 'Delivery Address' }}
|
|
5
5
|
</div>
|
|
6
6
|
<div class="OrderBillingInformation__form">
|
|
7
7
|
<validation-observer
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
<div class="OrderBillingInformation__content">
|
|
11
11
|
<address-form
|
|
12
12
|
:address="order.shippingAddress"
|
|
13
|
-
:only-contact-info="
|
|
13
|
+
:only-contact-info="needToPickupWithoutErrors"
|
|
14
14
|
:without-additional-info="true" />
|
|
15
15
|
<div
|
|
16
|
-
v-if="!
|
|
16
|
+
v-if="!needToPickupWithoutErrors"
|
|
17
17
|
class="mt-20 mb-20">
|
|
18
18
|
<checkbox
|
|
19
19
|
v-model="copyToBillingAddress"
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
...mapGetters(['currency'])
|
|
79
79
|
},
|
|
80
80
|
mounted() {
|
|
81
|
-
if (this.
|
|
81
|
+
if (this.needToPickupWithoutErrors) {
|
|
82
82
|
this.copyToBillingAddress = false;
|
|
83
83
|
}
|
|
84
84
|
},
|
|
@@ -86,7 +86,7 @@ export default {
|
|
|
86
86
|
async submit() {
|
|
87
87
|
this.isSubmit = true;
|
|
88
88
|
|
|
89
|
-
const isValid = await this.$refs.form.validate() && (!!this.order.shippingAddress.postcode || this.
|
|
89
|
+
const isValid = await this.$refs.form.validate() && (!!this.order.shippingAddress.postcode || this.needToPickupWithoutErrors);
|
|
90
90
|
if (!isValid) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -76,6 +76,7 @@ export const getters = {
|
|
|
76
76
|
entities: ({ entities }) => entities,
|
|
77
77
|
coupon: ({ coupon }) => coupon,
|
|
78
78
|
needToPickup: ({ needToPickup }) => needToPickup,
|
|
79
|
+
needToPickupWithoutErrors: (state, { notValidProductsPickup }) => state.needToPickup && notValidProductsPickup?.length === 0,
|
|
79
80
|
cartPricingCalculating: ({ cartPricingCalculating }) => cartPricingCalculating,
|
|
80
81
|
simpleProducts: ({ entities }) => entities.reduce((simpleProducts, entity) => [...simpleProducts, ...(entity.simpleProducts || [])], []),
|
|
81
82
|
notEmptySimpleProducts: (state, { simpleProducts }) => simpleProducts.filter(e => e.amount > 0),
|
|
@@ -189,7 +190,7 @@ export const actions = {
|
|
|
189
190
|
await api.saveCart(payload, shop._id);
|
|
190
191
|
commit('setEntities', entities);
|
|
191
192
|
},
|
|
192
|
-
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing,
|
|
193
|
+
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, getters: { needToPickupWithoutErrors }, commit }, { shop, country, currency }) {
|
|
193
194
|
let savedSuppliersWithRates = null;
|
|
194
195
|
try {
|
|
195
196
|
savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
|
|
@@ -199,7 +200,7 @@ export const actions = {
|
|
|
199
200
|
console.log('calculateCartPrice:payload: ', payload)
|
|
200
201
|
try {
|
|
201
202
|
commit('setCartPricingCalculating', true);
|
|
202
|
-
const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
|
|
203
|
+
const response = await api.calculateProductPrice({ ...payload, needToPickup: needToPickupWithoutErrors }, shop._id);
|
|
203
204
|
commit('setCartPricing', response);
|
|
204
205
|
commit('setCartPricingError', null);
|
|
205
206
|
} catch (e) {
|