@nuskin/ns-shop 7.0.11-pur-813.4 → 7.0.11-pur-813.6

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.0.11-pur-813.4",
3
+ "version": "7.0.11-pur-813.6",
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": {
@@ -262,6 +262,13 @@ const getProductBySku = async (options) => {
262
262
  return result;
263
263
  }
264
264
 
265
+ const getProductData = async (options) => {
266
+ const data = await getProductDetail(options);
267
+
268
+ return createDataFromSkuSearch(data, options);
269
+ }
270
+
265
271
  export {
266
- getProductBySku
272
+ getProductBySku,
273
+ getProductData
267
274
  }
@@ -1,11 +1,10 @@
1
- import $ from '@nuskin/nuskinjquery';
2
1
  import {PriceType, Product} from '@nuskin/ns-product-lib';
3
2
  import {RunConfigService, events, util, BrowserDetection, UrlService} from '@nuskin/ns-util';
4
3
  import {UserService, AccountManager} from '@nuskin/ns-account';
5
4
  import ProductStatusService from '../product/ProductStatusService.js';
6
5
  import _ from 'lodash';
7
6
  import { getConfiguration } from '@nuskin/configuration-sdk';
8
- import { getProductBySku as getCsProductBySku } from './csProductHelper.js';
7
+ import { getProductBySku as getCsProductBySku, getProductData as getCsProductData } from './csProductHelper.js';
9
8
  import axios from 'axios';
10
9
 
11
10
  let ProductService = function() {
@@ -37,35 +36,48 @@ let ProductService = function() {
37
36
  * @param {string} sku - ex. 01111155
38
37
  * @returns {Promise}
39
38
  */
40
- getProductData: function(sku, country, language) {
41
- if(!sku) return;
42
- let optionsData = country ? {country} : {};
43
- if(language)
44
- optionsData.language = language;
45
-
46
- let tokenizedSku = tokenizeSku(sku),
47
- url,
48
- options = verifyLocaleFields(optionsData);
49
-
50
- url = UrlService.getSiteUrl() + "/content/products/" + tokenizedSku + "/" +
51
- options.language + ".service." + options.country + ".json";
52
-
53
- return new Promise((resolve, reject) => {
54
- $.ajax({
55
- type: 'GET',
56
- url: url,
57
- success: function(response) {
58
- resolve(createDataFromSkuSearch(response, options));
59
- },
60
- error: function(response) {
61
- console.error("There was a problem retrieving product data:", response);
62
- reject(response);
39
+ getProductData: async function(sku, country, language) {
40
+ let retVal;
41
+
42
+ if (sku) {
43
+ const optionsData = {
44
+ country: country ? country : undefined,
45
+ language: language ? language : undefined,
46
+ sku
47
+ };
48
+ const options = verifyLocaleFields(optionsData);
49
+ const {Cart: cartCfg} = await getConfiguration(['Cart']);
50
+
51
+ try {
52
+
53
+ if (cartCfg.useContentStackProductData) {
54
+ retVal = await getCsProductData(options);
55
+ } else {
56
+ const tokenizedSku = tokenizeSku(sku);
57
+ const url = UrlService.getSiteUrl() + "/content/products/" + tokenizedSku + "/" +
58
+ options.language + ".service." + options.country + ".json";
59
+ const response = await axios.get(url);
60
+ retVal = createDataFromSkuSearch(response, options);
63
61
  }
64
- });
65
- });
66
-
67
-
68
-
62
+ } catch (err) {
63
+ console.error("There was a problem retrieving product data", err);
64
+ }
65
+ }
66
+ return retVal;
67
+
68
+ // return new Promise((resolve, reject) => {
69
+ // $.ajax({
70
+ // type: 'GET',
71
+ // url: url,
72
+ // success: function(response) {
73
+ // resolve(createDataFromSkuSearch(response, options));
74
+ // },
75
+ // error: function(response) {
76
+ // console.error("There was a problem retrieving product data:", response);
77
+ // reject(response);
78
+ // }
79
+ // });
80
+ // });
69
81
  }
70
82
  };
71
83
 
@@ -182,13 +182,16 @@ let PickupUtil = function() {
182
182
  includePickupPoints = includePickupPoints && !postalCode.match(regEx);
183
183
  }
184
184
 
185
+ const runConfig = RunConfigService.getRunConfig();
185
186
  promise = axios.post(
186
187
  getUrl(),
187
188
  {
188
189
  order,
189
190
  pudo: includePickupPoints,
190
191
  orderValue: getOrderValue(),
191
- dangerousGoods: CartService.hasDangerousGoods()
192
+ dangerousGoods: CartService.hasDangerousGoods(),
193
+ language: runConfig.language,
194
+ country: runConfig.country
192
195
  },
193
196
  {
194
197
  headers: {
@@ -198,7 +201,11 @@ let PickupUtil = function() {
198
201
  ).then((results) => {
199
202
  shipMethods = results.data.shipMethods;
200
203
  pickupPoints = results.data.pickupPoints;
201
- })
204
+ }).catch((err) => {
205
+ console.log(err);
206
+ shipMethods = [];
207
+ pickupPoints = [];
208
+ });
202
209
  }
203
210
  }
204
211