@nuskin/ns-shop 5.19.3 → 5.19.5
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
package/src/cart/cartService.js
CHANGED
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
getAddToCartQty,
|
|
39
39
|
changeItemQty,
|
|
40
40
|
syncCartItemToSapItem,
|
|
41
|
-
|
|
41
|
+
checkItemAvailability,
|
|
42
42
|
removeItemBySku,
|
|
43
43
|
removeItemByKey,
|
|
44
44
|
removeItems,
|
|
@@ -107,6 +107,10 @@ function _getCart() {
|
|
|
107
107
|
anonymousCartId = storage.getItem('anonymousCartId'),
|
|
108
108
|
isPitchApp = PersonalOfferStorageService.isPersonalOffer();
|
|
109
109
|
|
|
110
|
+
if (cartJson && !cartJson.cntryCd) {
|
|
111
|
+
cartJson.cntryCd = runConfig.country;
|
|
112
|
+
}
|
|
113
|
+
|
|
110
114
|
// If the cartJson userId is empty OR null, then we are going from nothing to something, and we want to keep our items
|
|
111
115
|
if (cartJson &&
|
|
112
116
|
(!UrlService.isLocalePage() || (cartJson.cntryCd === runConfig.country)) &&
|
|
@@ -290,6 +294,17 @@ function getPriceTypeTotal(priceType) {
|
|
|
290
294
|
}).reduce((a, b) => a + b, 0);
|
|
291
295
|
}
|
|
292
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Checks status and order types.
|
|
299
|
+
*
|
|
300
|
+
* @param {*} product
|
|
301
|
+
* @returns
|
|
302
|
+
*/
|
|
303
|
+
function itemIsAvailable(product) {
|
|
304
|
+
return product.status === ProductStatus.ReleasedForSale &&
|
|
305
|
+
(product.hasOrderOption() || product.hasAdrOption());
|
|
306
|
+
}
|
|
307
|
+
|
|
293
308
|
/**
|
|
294
309
|
* Adds a product to the cart. If is not a SAP product it checks for excusivity before
|
|
295
310
|
* adding to the cart.
|
|
@@ -313,7 +328,7 @@ function getPriceTypeTotal(priceType) {
|
|
|
313
328
|
async function addProductToCart(options) {
|
|
314
329
|
let cart = _getCart();
|
|
315
330
|
|
|
316
|
-
if (options.product
|
|
331
|
+
if (!itemIsAvailable(options.product)) {
|
|
317
332
|
throw new NsProductNotReleasedForSale('This product is not released for sale');
|
|
318
333
|
}
|
|
319
334
|
|
|
@@ -785,17 +800,18 @@ function syncCartItemToSapItem(sapItemKey, cartItemKey = null) {
|
|
|
785
800
|
* quantity is at or below qualified amounts. If the quantity in
|
|
786
801
|
* the cart is too high an adjustment is made.
|
|
787
802
|
*/
|
|
788
|
-
async function
|
|
803
|
+
async function checkItemAvailability() {
|
|
789
804
|
const cart = _getCart();
|
|
790
|
-
const itemData = cart.getItemData();
|
|
791
805
|
|
|
792
|
-
for (const item of
|
|
793
|
-
if (item.
|
|
794
|
-
|
|
806
|
+
for (const item of cart.getItems()) {
|
|
807
|
+
if (!itemIsAvailable(item.product)) {
|
|
808
|
+
cart.removeProduct(item.key);
|
|
809
|
+
} else if (item.product.isExclusive) {
|
|
810
|
+
const qual = await QualificationService.getQualification(item.product.sku);
|
|
795
811
|
const qualCnt = qual ? qual.quantity : 0;
|
|
796
812
|
|
|
797
813
|
if (qualCnt < item.qty) {
|
|
798
|
-
await changeItemQty(item, qualCnt, 'qualification check');
|
|
814
|
+
await changeItemQty(item.toFlatJson(), qualCnt, 'qualification check');
|
|
799
815
|
}
|
|
800
816
|
}
|
|
801
817
|
}
|
|
@@ -673,7 +673,7 @@ const mergeIntoLocalCart = async (userId, pCart) => {
|
|
|
673
673
|
});
|
|
674
674
|
|
|
675
675
|
await Promise.allSettled(promises);
|
|
676
|
-
await CartService.
|
|
676
|
+
await CartService.checkItemAvailability();
|
|
677
677
|
await adjustPCart(pCart);
|
|
678
678
|
}
|
|
679
679
|
mergingIntoLocalCart = false;
|
|
@@ -305,7 +305,7 @@ const addContactInfo = (contacts, selectedAddress) => {
|
|
|
305
305
|
//Only push contacts if they aren't empty
|
|
306
306
|
if (selectedAddress.shippingPhone) {
|
|
307
307
|
contacts.push({
|
|
308
|
-
Country: selectedAddress.shippingCountry,
|
|
308
|
+
Country: selectedAddress.shippingPhoneCountry || selectedAddress.shippingCountry,
|
|
309
309
|
Value: {
|
|
310
310
|
value: selectedAddress.shippingPhone,
|
|
311
311
|
Type: "HOMEPHONE"
|