@nuskin/ns-shop 7.0.9-cx24-7079.1 → 7.0.9
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 +2 -2
- package/src/cart/equinoxCartService.js +12 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/ns-shop",
|
|
3
|
-
"version": "7.0.9
|
|
3
|
+
"version": "7.0.9",
|
|
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": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@nuskin/ns-common-lib": "1.4.7",
|
|
27
27
|
"@nuskin/ns-feature-flags": "1.4.7",
|
|
28
28
|
"@nuskin/ns-loyalty-web": "1.5.6",
|
|
29
|
-
"@nuskin/ns-product-lib": "2.17.
|
|
29
|
+
"@nuskin/ns-product-lib": "2.17.6",
|
|
30
30
|
"@nuskin/nuskinjquery": "2.3.1",
|
|
31
31
|
"axios": "1.6.5",
|
|
32
32
|
"decimal.js": "10.4.3",
|
|
@@ -20,8 +20,7 @@ const shoppingContextCartTypes = {
|
|
|
20
20
|
|
|
21
21
|
const DEFAULT_CART_TYPE = 'USER';
|
|
22
22
|
|
|
23
|
-
let
|
|
24
|
-
let promise = null;
|
|
23
|
+
let cartContents = null;
|
|
25
24
|
|
|
26
25
|
export default {
|
|
27
26
|
addProductToEquinoxCart,
|
|
@@ -224,25 +223,22 @@ function _getCartShoppingContext() {
|
|
|
224
223
|
async function getEquinoxCart() {
|
|
225
224
|
|
|
226
225
|
const cartType = _getCartShoppingContext();
|
|
227
|
-
|
|
226
|
+
|
|
228
227
|
const equinoxRequestOptions = {
|
|
229
228
|
method: 'GET',
|
|
230
229
|
endpoint: `carts/${cartType}`
|
|
231
230
|
}
|
|
232
|
-
if(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
requestStatus = 'pending';
|
|
237
|
-
promise = _equinoxRequest(equinoxRequestOptions);
|
|
238
|
-
return resolvePromise(promise);
|
|
231
|
+
if (!cartContents){
|
|
232
|
+
cartContents = _equinoxRequest(equinoxRequestOptions).then(result => {
|
|
233
|
+
cartContents = result;
|
|
234
|
+
});
|
|
239
235
|
}
|
|
240
|
-
}
|
|
241
236
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
237
|
+
await cartContents
|
|
238
|
+
|
|
239
|
+
// if this is a promise, this will resolve it
|
|
240
|
+
// otherwise, it won't do anything
|
|
241
|
+
return cartContents;
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
/**
|
|
@@ -471,6 +467,7 @@ const runConfigCallback = async (runConfig) => {
|
|
|
471
467
|
const publishEquinoxCartCount = (options) => {
|
|
472
468
|
getEquinoxCart().then((response) => {
|
|
473
469
|
const cart = response.data;
|
|
470
|
+
cartContents = null;
|
|
474
471
|
events.publish(events.shop.CART_UPDATED, { cartInfo: { qty: cart.value.count }, ...options });
|
|
475
472
|
});
|
|
476
473
|
}
|