@viur/shop-components 0.15.2 → 0.15.3
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/package.json +1 -1
- package/src/composables/cart.js +11 -11
package/package.json
CHANGED
package/src/composables/cart.js
CHANGED
|
@@ -41,16 +41,10 @@ export function useCart() {
|
|
|
41
41
|
if (_fetchCartPromise) return _fetchCartPromise;
|
|
42
42
|
|
|
43
43
|
shopStore.state.cartIsLoading = true;
|
|
44
|
-
let promise
|
|
45
|
-
|
|
46
|
-
shopStore.state.cartRoot
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
promise = fetchCartRoot().then(() => {
|
|
50
|
-
if (!shopStore.state.cartRoot?.["key"]) return 0;
|
|
51
|
-
return fetchCartItems(shopStore.state.cartRoot["key"]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
44
|
+
let promise = fetchCartRoot().then(() => {
|
|
45
|
+
if (!shopStore.state.cartRoot?.["key"]) return 0;
|
|
46
|
+
return fetchCartItems(shopStore.state.cartRoot["key"]);
|
|
47
|
+
});
|
|
54
48
|
|
|
55
49
|
_fetchCartPromise = promise.then(() => {
|
|
56
50
|
shopStore.state.cartIsLoading = false;
|
|
@@ -69,6 +63,8 @@ export function useCart() {
|
|
|
69
63
|
shopStore.state.cartRoot = data.filter(i=>i['cart_type']==='basket')?.[0] ? data.filter(i=>i['cart_type']==='basket')[0]:[]
|
|
70
64
|
if (shopStore.state.cartRoot.discount){
|
|
71
65
|
shopStore.state.discounts = {[shopStore.state.cartRoot.discount.dest.key]:shopStore.state.cartRoot.discount}
|
|
66
|
+
} else {
|
|
67
|
+
shopStore.state.discounts = {}
|
|
72
68
|
}
|
|
73
69
|
return resp
|
|
74
70
|
})
|
|
@@ -97,7 +93,11 @@ export function useCart() {
|
|
|
97
93
|
let discounts = {}
|
|
98
94
|
return _collectCartItems(key, leafs, discounts).then((resp) => {
|
|
99
95
|
shopStore.state.cartList = leafs
|
|
100
|
-
|
|
96
|
+
// Include root-level discount alongside node-level discounts
|
|
97
|
+
if (shopStore.state.cartRoot?.discount) {
|
|
98
|
+
discounts[shopStore.state.cartRoot.discount.dest.key] = shopStore.state.cartRoot.discount
|
|
99
|
+
}
|
|
100
|
+
shopStore.state.discounts = discounts
|
|
101
101
|
|
|
102
102
|
return resp
|
|
103
103
|
})
|