@nuskin/ns-shop 5.14.10 → 5.14.12
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/cart/cart.js +13 -1
- package/src/cart/persistentCartService.js +21 -13
- package/src/order/orderAdapter.js +1 -3
package/package.json
CHANGED
package/src/cart/cart.js
CHANGED
|
@@ -150,13 +150,25 @@ export default function Cart(cartData) {
|
|
|
150
150
|
this.addCartItem = function(cartItem, replace, referrer) {
|
|
151
151
|
if (cartItem instanceof CartItem && cartItem.product) {
|
|
152
152
|
cartItem.key = getItemKey(cartItem);
|
|
153
|
+
const origItem = itemTable.get(cartItem.key);
|
|
153
154
|
itemTable.add(cartItem, replace);
|
|
154
155
|
if (cartItem.isSapLineItem()) {
|
|
155
156
|
updateSapTotals();
|
|
156
157
|
} else {
|
|
157
158
|
updateCartTotals();
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
+
if (replace && origItem) {
|
|
161
|
+
publish(events.shop.CART_UPDATED, {
|
|
162
|
+
modify: {
|
|
163
|
+
type: 'quantity-changed',
|
|
164
|
+
key: cartItem.key,
|
|
165
|
+
item: cartItem.toFlatJson(),
|
|
166
|
+
qtyDiff: cartItem.qty - origItem.qty
|
|
167
|
+
}
|
|
168
|
+
}, referrer);
|
|
169
|
+
} else {
|
|
170
|
+
publish(events.shop.CART_UPDATED, {add: {item: cartItem.toFlatJson()}}, referrer);
|
|
171
|
+
}
|
|
160
172
|
}
|
|
161
173
|
};
|
|
162
174
|
|
|
@@ -690,24 +690,32 @@ const persistCartUpdates = async () => {
|
|
|
690
690
|
let loadCartType = null;
|
|
691
691
|
|
|
692
692
|
if (pcActions.hasItems()) {
|
|
693
|
-
removeCart = pcActions.hasRemoveCartItem();
|
|
694
|
-
loadCartType = pcActions.hasLoadCartItem();
|
|
693
|
+
// removeCart = pcActions.hasRemoveCartItem();
|
|
694
|
+
// loadCartType = pcActions.hasLoadCartItem();
|
|
695
695
|
|
|
696
696
|
// even though there is no need to process the queue if there is a removeCart
|
|
697
697
|
// or a loadCart action they still need to get marked as processed so they will
|
|
698
698
|
// get removed.
|
|
699
699
|
let info = pcActions.peek();
|
|
700
700
|
while (info) {
|
|
701
|
-
if (info.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
} else
|
|
708
|
-
|
|
701
|
+
if (info.removeCart) {
|
|
702
|
+
removeCart = true;
|
|
703
|
+
info = null;
|
|
704
|
+
} else if (info.loadCart) {
|
|
705
|
+
loadCartType = info.loadCart.type;
|
|
706
|
+
info = null;
|
|
707
|
+
} else {
|
|
708
|
+
if (info.add && info.add.item.qty > 0) {
|
|
709
|
+
handleAddAction(info.add, actions);
|
|
710
|
+
} else if (info.modify) {
|
|
711
|
+
handleModifyAction(info.modify, actions);
|
|
712
|
+
} else if (info.remove) {
|
|
713
|
+
handleRemoveAction(info.remove, actions);
|
|
714
|
+
} else if (info.removeItems) {
|
|
715
|
+
handleRemoveItemsAction(info.removeItems, actions);
|
|
716
|
+
}
|
|
717
|
+
info = pcActions.peekNext();
|
|
709
718
|
}
|
|
710
|
-
info = pcActions.peekNext();
|
|
711
719
|
}
|
|
712
720
|
}
|
|
713
721
|
|
|
@@ -717,10 +725,10 @@ const persistCartUpdates = async () => {
|
|
|
717
725
|
if (loadCartType) {
|
|
718
726
|
await syncCart(loadCartType);
|
|
719
727
|
}
|
|
728
|
+
pcActions.clear();
|
|
720
729
|
if (!(removeCart || loadCartType) && actions.length > 0) {
|
|
721
730
|
await doPersistentUpdates(actions, pcId, pcVersion, pcType);
|
|
722
731
|
}
|
|
723
|
-
pcActions.clear();
|
|
724
732
|
if (pcActions.hasItems()) {
|
|
725
733
|
clearTimeout(timerId);
|
|
726
734
|
timerId = setTimeout(timerCallback, 200);
|
|
@@ -765,7 +773,7 @@ const addAction = (info) => {
|
|
|
765
773
|
clearTimeout(timerId);
|
|
766
774
|
timerId = 0;
|
|
767
775
|
if (!persistingCart) {
|
|
768
|
-
if (info.removeCart) {
|
|
776
|
+
if (info.removeCart || pcActions.hasRemoveCartItem()) {
|
|
769
777
|
// Likely a page refresh coming, wait for it to happen.
|
|
770
778
|
// The cart actions will be picked up there.
|
|
771
779
|
timerId = setTimeout(timerCallback, 1000);
|
|
@@ -117,7 +117,6 @@ const populateItem = (order, salesOrder, shipImmediate, includeSapItems) => {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
-
|
|
121
120
|
/*
|
|
122
121
|
const populateAttribution = (salesOrder) => {
|
|
123
122
|
const sponsorId = util.getSponsorId();
|
|
@@ -131,8 +130,7 @@ const populateAttribution = (salesOrder) => {
|
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
|
-
*/
|
|
135
|
-
|
|
133
|
+
*/
|
|
136
134
|
const populateShipping = (order, salesOrder) => {
|
|
137
135
|
let nsConfig = ConfigService.getMarketConfig();
|
|
138
136
|
let user = UserService.getUser();
|