@nuskin/ns-shop 7.1.1-pur-813.3 → 7.1.1-pur-813.5

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.3",
3
+ "version": "7.1.1-pur-813.5",
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() {
@@ -154,7 +154,8 @@ const populateAttribution = (salesOrder) => {
154
154
 
155
155
  const populateShipping = (order, salesOrder) => {
156
156
  const user = UserService.getUser();
157
- const defaultCode = getCachedConfigField('defaultShipMethod');
157
+ const useShipMethodsApi = getCachedConfigField('useShipMethodsApi')
158
+ const defaultCode = useShipMethodsApi ? getCachedConfigField('defaultShipMethod') : '';
158
159
  const method = order.selectedShippingMethod;
159
160
  const code = method ? method.Code : defaultCode;
160
161