@nuskin/ns-shop 7.9.0-mdigi-6056.5 → 7.9.1-td-4379.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
|
@@ -31,6 +31,7 @@ export default {
|
|
|
31
31
|
getEquinoxRequestConfiguration,
|
|
32
32
|
_getEquinoxSession,
|
|
33
33
|
_getCartShoppingContext,
|
|
34
|
+
_getSessionShoppingContext,
|
|
34
35
|
_equinoxRequest,
|
|
35
36
|
goToCartPage,
|
|
36
37
|
_assembleChildSkus,
|
|
@@ -201,15 +202,32 @@ async function addBundleToEquinoxCart(productBundleSkus = [], products = [], ava
|
|
|
201
202
|
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
/**
|
|
206
|
+
* _getSessionShoppingContext - retrieves shopping context from storage or sessionStorage
|
|
207
|
+
* @returns { Object|null } - The shopping context object or null if not found
|
|
208
|
+
*/
|
|
209
|
+
function _getSessionShoppingContext() {
|
|
210
|
+
let shoppingContext = sessionStorage.getItem(storage.keys.SHOPPING_CONTEXT);
|
|
211
|
+
if (shoppingContext) {
|
|
212
|
+
try {
|
|
213
|
+
shoppingContext = JSON.parse(shoppingContext);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
shoppingContext = null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return shoppingContext;
|
|
219
|
+
}
|
|
220
|
+
|
|
204
221
|
/**
|
|
205
222
|
* _getCartShoppingContext - set cart type based on storage shopping context
|
|
206
223
|
* @returns { String }
|
|
207
224
|
*/
|
|
208
225
|
function _getCartShoppingContext() {
|
|
209
226
|
let cartType = DEFAULT_CART_TYPE;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
227
|
+
let shoppingContext = storage.getItem(storage.keys.SHOPPING_CONTEXT);
|
|
228
|
+
if (!shoppingContext) {
|
|
229
|
+
shoppingContext = _getSessionShoppingContext();
|
|
230
|
+
}
|
|
213
231
|
if (shoppingContext && shoppingContextCartTypes[shoppingContext.context]) {
|
|
214
232
|
cartType = shoppingContextCartTypes[shoppingContext.context];
|
|
215
233
|
}
|
|
@@ -291,13 +309,18 @@ async function getAddToCartQty(product) {
|
|
|
291
309
|
*/
|
|
292
310
|
async function getEquinoxRequestConfiguration() {
|
|
293
311
|
const cartType = _getCartShoppingContext();
|
|
312
|
+
const shoppingContext = _getSessionShoppingContext();
|
|
294
313
|
const marketLocale = UrlService.getLocale();
|
|
295
314
|
const [, market] = marketLocale.split("_");
|
|
296
315
|
const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
|
|
297
316
|
|
|
298
317
|
// Use MySite_API_Base_URLs if it is in MySite or MSCART
|
|
299
318
|
const isMysite = cartType === shoppingContextCartTypes.storefront || window.location.hostname.includes(".mynuskin.com");
|
|
300
|
-
|
|
319
|
+
let baseURL = isMysite ? config.MySite_API_Base_URLs : config.API_Base_URLs;
|
|
320
|
+
|
|
321
|
+
if(shoppingContext && shoppingContext.context === 'storefront'){
|
|
322
|
+
baseURL = config.API_Base_URLs;
|
|
323
|
+
}
|
|
301
324
|
|
|
302
325
|
let mySiteKongURL = baseURL.includes(isMysite ? "storefront" : "apis")
|
|
303
326
|
? baseURL
|
|
@@ -367,13 +390,36 @@ function goToCartPage() {
|
|
|
367
390
|
const [locale, market] = UrlService.getLocale().split("_");
|
|
368
391
|
const currentEnvironment = RunConfigService.getEnvironmentCode();
|
|
369
392
|
const env = currentEnvironment !== 'prod' ? 'test.' : '';
|
|
370
|
-
|
|
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
|
+
}
|
|
371
407
|
|
|
372
408
|
let url = `https://${env}nuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/viewCart`;
|
|
373
409
|
|
|
374
410
|
if (shoppingContext && shoppingContext.context === "storefront") {
|
|
375
411
|
url = `https://mysite.${env}mynuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/viewCart`;
|
|
376
412
|
}
|
|
413
|
+
|
|
414
|
+
if (sessionStorefront && sessionStorefront.user.shopUrl && sessionStorefront.user.sapId) {
|
|
415
|
+
if (shoppingContext && shoppingContext.context === "storefront") {
|
|
416
|
+
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') {
|
|
419
|
+
const sapId = sessionStorefront.user.sapId;
|
|
420
|
+
url = `https://${env}nuskin.com/${market.toLowerCase()}/${locale.toLowerCase()}/personal-offer/${sapId}/viewCart`;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
377
423
|
|
|
378
424
|
window.location = url;
|
|
379
425
|
}
|