@nuskin/ns-shop 7.9.1-td-4379.1 → 7.9.1-td-4379.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": "@nuskin/ns-shop",
3
- "version": "7.9.1-td-4379.1",
3
+ "version": "7.9.1-td-4379.3",
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": {
@@ -34,6 +34,7 @@ export default {
34
34
  _getSessionShoppingContext,
35
35
  _equinoxRequest,
36
36
  goToCartPage,
37
+ getSessionShopURL,
37
38
  _assembleChildSkus,
38
39
  _assembleAdrProperties
39
40
  }
@@ -390,38 +391,40 @@ function goToCartPage() {
390
391
  const [locale, market] = UrlService.getLocale().split("_");
391
392
  const currentEnvironment = RunConfigService.getEnvironmentCode();
392
393
  const env = currentEnvironment !== 'prod' ? 'test.' : '';
393
- let shoppingContext = storage.getItem(storage.keys.SHOPPING_CONTEXT);
394
- let sessionStorefront = sessionStorage.getItem(storage.keys.STOREFRONT);
395
-
396
- if (!shoppingContext) {
397
- shoppingContext = _getSessionShoppingContext();
398
- }
399
-
400
- if (sessionStorefront) {
401
- try {
402
- sessionStorefront = JSON.parse(sessionStorefront);
403
- } catch (e) {
404
- sessionStorefront = null;
405
- }
406
- }
394
+ const shoppingContext = storage.getItem(storage.keys.SHOPPING_CONTEXT);
407
395
 
408
396
  let url = `https://${env}nuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/viewCart`;
409
397
 
410
398
  if (shoppingContext && shoppingContext.context === "storefront") {
411
399
  url = `https://mysite.${env}mynuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/viewCart`;
400
+ } else if (!shoppingContext) {
401
+ const sessionUrl = getSessionShopURL();
402
+ if (sessionUrl) {
403
+ url = `https://${env}nuskin.com/${sessionUrl}`;
404
+ }
412
405
  }
406
+
407
+ window.location = url;
408
+ }
409
+
410
+ //Gets the shop URL and sapId from session storage.
411
+ function getSessionShopURL() {
412
+ const [locale, market] = UrlService.getLocale().split("_");
413
+ const shoppingContext = _getSessionShoppingContext();
414
+ const sessionStorefront = sessionStorage.getItem('storefront') ? JSON.parse(sessionStorage.getItem('storefront')) : null;
415
+ let url;
413
416
 
414
- if (sessionStorefront && sessionStorefront.user.shopUrl && sessionStorefront.user.sapId) {
417
+ if (sessionStorefront && sessionStorefront.user && sessionStorefront.user.shopUrl) {
415
418
  if (shoppingContext && shoppingContext.context === "storefront") {
416
419
  const shopUrl = sessionStorefront.user.shopUrl;
417
- url = `https://${env}nuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/mysite/${shopUrl}/viewCart`;
418
- } else if (shoppingContext && shoppingContext.context === 'personal_offer') {
420
+ url = `${market.toLowerCase()}/${locale.toLowerCase()}/mysite/${shopUrl}/viewCart`;
421
+ } else if (shoppingContext && shoppingContext.context === 'personal_offer' && sessionStorefront.user.sapId) {
419
422
  const sapId = sessionStorefront.user.sapId;
420
- url = `https://${env}nuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/personal-offer/${sapId}/viewCart`;
423
+ url = `${market.toLowerCase()}/${locale.toLowerCase()}/personal-offer/${sapId}/viewCart`;
421
424
  }
422
425
  }
423
-
424
- window.location = url;
426
+
427
+ return url;
425
428
  }
426
429
 
427
430
  /**