@nuskin/ns-shop 7.7.0-6056-insider.1 → 7.7.0-cdb-1.1

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": "@nuskin/ns-shop",
3
- "version": "7.7.0-6056-insider.1",
3
+ "version": "7.7.0-cdb-1.1",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
package/src/cart/cart.js CHANGED
@@ -1414,11 +1414,7 @@ export default function Cart(cartData) {
1414
1414
  'name': flatItem.title,
1415
1415
  'id': flatItem.sku,
1416
1416
  'price': flatItem.price,
1417
- 'quantity': Math.abs(diffQty),
1418
- 'taxonomy': flatItem.taxonomy,
1419
- 'sales_price': flatItem.salesPrice,
1420
- 'unit_price': flatItem.unitPrice,
1421
- 'product_image_url': flatItem.product_image_url
1417
+ 'quantity': Math.abs(diffQty)
1422
1418
  });
1423
1419
 
1424
1420
  function getCartInfo(options) {
@@ -293,30 +293,6 @@ export default function CartItem(cartItemData) {
293
293
  return this.product.marketAttributes;
294
294
  }
295
295
 
296
- this.unitPrice = function () {
297
- if (AccountManager.isCustomer() || AccountManager.isPreferredCustomer()) {
298
- return this.product.priceMap.RTL;
299
- } else if (AccountManager.isDistributor()) {
300
- return this.product.priceMap.WHL;
301
- }
302
- }
303
-
304
- this.salesPrice = function () {
305
- if (AccountManager.isCustomer() || AccountManager.isPreferredCustomer()) {
306
- if (this.product.priceType.WADR) {
307
- return this.product.priceMap.WADR;
308
- } else {
309
- return this.product.priceMap.RTL;
310
- }
311
- } else if (AccountManager.isDistributor()) {
312
- if (this.product.priceType.WADR) {
313
- return this.product.priceMap.WADW;
314
- } else {
315
- return this.product.priceMap.WHL;
316
- }
317
- }
318
- }
319
-
320
296
  this.toFlatJson = function() {
321
297
  let retVal = {};
322
298
 
@@ -376,10 +352,6 @@ export default function CartItem(cartItemData) {
376
352
  retVal.size = this.product.size;
377
353
  retVal.variants = this.product.variants;
378
354
  retVal.marketAttributes = this.product.marketAttributes;
379
- retVal.product_image_url = this.product.fullImage;
380
- retVal.taxonomy = this.product.title ? this.product.title.split(' ')[0] : '';
381
- retVal.salesPrice = AccountManager.isLoggedIn()? this.salesPrice() : null;
382
- retVal.unitPrice = AccountManager.isLoggedIn()? this.unitPrice() : null;
383
355
 
384
356
  return retVal;
385
357
  };
@@ -55,6 +55,7 @@ export default {
55
55
  adrHasAgelocMe,
56
56
  setSignupMode,
57
57
  inSignupMode,
58
+ currentUserCanAddToCart,
58
59
  minAdrPsvMet,
59
60
  checkProductLanguages,
60
61
  scanQualifiedCnt,
@@ -671,6 +672,50 @@ function inSignupMode() {
671
672
  return cart ? cart.inSignup : false;
672
673
  }
673
674
 
675
+ /**
676
+ * Determines if the current user has permission to add items to cart based on market restrictions.
677
+ * Checks if users from markets configured in 'foreignOrderingRestrictedMarkets' are attempting
678
+ * to add items in foreign markets.
679
+ *
680
+ * @memberof CartService
681
+ * @example
682
+ * const canAdd = await CartService.currentUserCanAddToCart();
683
+ * if (!canAdd) {
684
+ * // Show popup notification to user
685
+ * }
686
+ *
687
+ * @returns {Promise<boolean>} Promise that resolves to true if current user can add items to cart, false if restricted
688
+ */
689
+ async function currentUserCanAddToCart() {
690
+ // If no user is logged in, allow adding to cart (no restrictions for anonymous users)
691
+ const user = UserService.getUser();
692
+ if (!user) {
693
+ return true;
694
+ }
695
+
696
+ // Get current market and user's home market
697
+ const runConfig = RunConfigService.getRunConfig();
698
+ const currentMarket = runConfig ? runConfig.country : null;
699
+ const userHomeMarket = user.countryCd;
700
+
701
+ // If we can't determine markets, allow adding to cart (fail open)
702
+ if (!currentMarket || !userHomeMarket) {
703
+ return true;
704
+ }
705
+
706
+ // Get Cart configuration to access foreign ordering restrictions
707
+ const { Cart: cartConfig } = await getConfiguration(['Cart']);
708
+ const foreignOrderingRestrictedMarkets = (cartConfig && cartConfig.foreignOrderingRestrictedMarkets) || [];
709
+
710
+ // Check if user's home market restricts foreign ordering
711
+ if (foreignOrderingRestrictedMarkets.includes(userHomeMarket) && currentMarket !== userHomeMarket) {
712
+ return false;
713
+ }
714
+
715
+ // All other cases are allowed
716
+ return true;
717
+ }
718
+
674
719
  function minAdrPsvMet() {
675
720
  let retVal = true,
676
721
  cart = _getCart(),
@@ -395,7 +395,7 @@ function _assembleChildSkus(requestData, options) {
395
395
  if (personalOffer !== null) {
396
396
  personalOffer = JSON.parse(personalOffer);
397
397
  productWithVariant = personalOffer.products.filter((sku) =>
398
- sku.type === 'bundle' && sku.variantSelected !== null && sku.sku === productSku
398
+ sku.type.toLowerCase() === 'bundle' && sku.variantSelected !== null && sku.sku === productSku
399
399
  )
400
400
  }
401
401
 
@@ -411,7 +411,7 @@ function _assembleChildSkus(requestData, options) {
411
411
  }
412
412
  if (personalOffer != null && selectedVariants && cs.skuId != selectedVariants[cs.productId] && (cs.type !== "BUNDLE" && cs.type !== "OPTIONAL")) return null
413
413
  const childSku =
414
- (personalOffer != null && selectedVariants && selectedVariants[cs.productId] && config.MySite_graphql_active)
414
+ (personalOffer != null && selectedVariants && selectedVariants[cs.productId] && config && config.MySite_graphql_active)
415
415
  ? {
416
416
  productId: cs.productId,
417
417
  skuId: selectedVariants[cs.productId],