@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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
- if (shopStore.state.order != null && shopStore.state.order?.cart?.dest.key) {
46
- shopStore.state.cartRoot = shopStore.state.order.cart.dest;
47
- promise = fetchCartItems(shopStore.state.cartRoot["key"]);
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
- Object.assign(shopStore.state.discounts, discounts)
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
  })