@nuskin/ns-shop 7.1.1-pur-813.2 → 7.1.1-pur-813.4

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.1.1-pur-813.2",
3
+ "version": "7.1.1-pur-813.4",
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": {
@@ -682,30 +682,30 @@ function minAdrPsvMet() {
682
682
  return retVal;
683
683
  }
684
684
 
685
- function checkProductLanguages() {
686
- let runConfig = RunConfigService.getRunConfig(null),
687
- options = {
688
- cntryCd: runConfig.country,
689
- language: runConfig.language
690
- };
691
-
692
- _getCart().getItems({cartItems: true}).forEach(_cartItem => {
693
- let cartItem = _cartItem;
694
-
685
+ async function checkProductLanguages() {
686
+ const runConfig = RunConfigService.getRunConfig(null);
687
+ const promises = [];
688
+ const changeditems = []
689
+ _getCart().getItems({cartItems: true}).forEach((cartItem) => {
695
690
  if (runConfig.language !== cartItem.product.lang) {
696
- options.sku = cartItem.product.sku;
697
- options.priceType = cartItem.product.priceType;
698
- ProductService.getProductBySku(options)
699
- .then((response) => {
700
- if (response.success && response.product) {
701
- let cart = _getCart();
702
-
703
- cart.changeProduct(cartItem.key, response.product);
704
- setCart(cart);
705
- }
706
- });
691
+ promises.push(ProductService.getProductBySku({
692
+ cntryCd: runConfig.country,
693
+ language: runConfig.language,
694
+ sku: cartItem.product.sku,
695
+ priceType: cartItem.product.priceType
696
+ }));
697
+ changeditems.push(cartItem);
707
698
  }
708
699
  });
700
+
701
+ if (promises.length > 0) {
702
+ const results = await Promise.all(promises);
703
+ let cart = _getCart();
704
+ results.forEach((result, i) => {
705
+ cart.changeProduct(changeditems[i].key, result.product);
706
+ });
707
+ setCart(cart);
708
+ }
709
709
  }
710
710
 
711
711
  function scanQualifiedCnt() {
@@ -153,12 +153,10 @@ const populateAttribution = (salesOrder) => {
153
153
  }
154
154
 
155
155
  const populateShipping = (order, salesOrder) => {
156
- let user = UserService.getUser();
157
- let code;
158
- let method = order.selectedShippingMethod;
159
- if (method) {
160
- code = method.Code;
161
- }
156
+ const user = UserService.getUser();
157
+ const defaultCode = getCachedConfigField('defaultShipMethod');
158
+ const method = order.selectedShippingMethod;
159
+ const code = method ? method.Code : defaultCode;
162
160
 
163
161
  //code = (util.countryCode === 'ZA') ? (order.selectedAddress.addressType == "home" ? "ZH" : "ST") : code;
164
162