@nuskin/ns-shop 5.20.13 → 5.20.14

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": "5.20.13",
3
+ "version": "5.20.14",
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": {
@@ -38,7 +38,7 @@
38
38
  "@nuskin/ns-account": "4.27.3",
39
39
  "@nuskin/ns-jsanalyzer": "1.0.1",
40
40
  "@nuskin/ns-product": "3.36.2",
41
- "@nuskin/ns-util": "3.99.2",
41
+ "@nuskin/ns-util": "3.102.2",
42
42
  "axios-mock-adapter": "1.18.2",
43
43
  "babel-cli": "6.26.0",
44
44
  "babel-core": "6.26.3",
@@ -1,7 +1,6 @@
1
1
  import {ConfigService, BrowserDetection} from "@nuskin/ns-util";
2
2
  import {AccountManager} from '@nuskin/ns-account';
3
3
  import {PriceType,Product} from '@nuskin/ns-product-lib';
4
- import FirebaseProduct from '../firebase/firebaseProduct.js';
5
4
 
6
5
  export default function CartItem(cartItemData) {
7
6
  if (!cartItemData.product) {
@@ -135,7 +134,7 @@ export default function CartItem(cartItemData) {
135
134
  };
136
135
 
137
136
  this.addAlternateBusinessPortfolio = function (altBpProduct) {
138
- if (altBpProduct instanceof Product || altBpProduct instanceof FirebaseProduct) {
137
+ if (altBpProduct instanceof Product) {
139
138
  const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
140
139
  ? PriceType.WWHL
141
140
  : this.product.priceType;
@@ -113,7 +113,7 @@ function _getCart() {
113
113
  let runConfig = RunConfigService.getRunConfig(null),
114
114
  user = UserService.getUser(),
115
115
  userId = user ? user.id : null,
116
- cartJson = storage.getItem({...CART_STORAGE_KEY, key: _getCartStorageName(runConfig.country)}),
116
+ cartJson = storage.getItem(CART_STORAGE_KEY),
117
117
  anonymousCartId = storage.getItem('anonymousCartId'),
118
118
  isPitchApp = PersonalOfferStorageService.isPersonalOffer();
119
119
 
@@ -138,7 +138,7 @@ function _getCart() {
138
138
 
139
139
  if (!cartJson.userId && userId != '') {
140
140
  cartJson.userId = userId;
141
- storage.setItem({...CART_STORAGE_KEY, key: _getCartStorageName(runConfig.country)}, cartJson);
141
+ storage.setItem(CART_STORAGE_KEY, cartJson);
142
142
  }
143
143
  _cart_ = new Cart(cartJson);
144
144
  let modified = _cart_.updateLineItemPrices(activeEvents);
@@ -164,35 +164,19 @@ function _getCart() {
164
164
  function setCart(cart, updateTimestamp = true) {
165
165
  if (cart != null && cart instanceof Cart) {
166
166
  cart.timestamp = updateTimestamp ? Date.now() : cart.timestamp;
167
- storage.setItem({...CART_STORAGE_KEY, key: _getCartStorageName(cart.cntryCd)}, cart.toJSON());
167
+ storage.setItem(CART_STORAGE_KEY, cart.toJSON());
168
168
  } else {
169
169
  if (cart) {
170
170
  cart.timestamp = updateTimestamp ? Date.now() : cart.timestamp;
171
- storage.setItem({...CART_STORAGE_KEY, key: _getCartStorageName(cart.cntryCd)}, cart);
171
+ storage.setItem(CART_STORAGE_KEY, cart);
172
172
  } else {
173
173
  cart = new Cart({cntryCd: RunConfigService.getRunConfig().country, userId: '', type: _cart_.type});
174
- storage.setItem({...CART_STORAGE_KEY, key: _getCartStorageName(cart.cntryCd)}, cart);
174
+ storage.setItem(CART_STORAGE_KEY, cart);
175
175
  }
176
176
  }
177
177
  _cart_ = cart;
178
178
  }
179
179
 
180
- /**
181
- * Gets the name of the cart to use. The name will either be shop-cart or, if
182
- * marketConfig.useMarketCarts is on, will be shop-cart-XX where XX is market.
183
- *
184
- * @param country
185
- * @return {string}
186
- * @private
187
- */
188
- function _getCartStorageName(country) {
189
- const nsConfig = ConfigService.getMarketConfig();
190
-
191
- return nsConfig.useMarketCarts
192
- ? `${CART_STORAGE_KEY.key}-${country}`
193
- : CART_STORAGE_KEY.key;
194
- }
195
-
196
180
  /**
197
181
  * Clears the cart from localStorage.
198
182
  *
@@ -834,9 +818,9 @@ async function checkItemAvailability() {
834
818
  const productInfo = await ProductService.getProductBySku({sku: item.product.sku});
835
819
  const qual = await QualificationService.getQualification(item.product.sku);
836
820
  let cartQty = 0;
837
- // if base sku
821
+ // if base sku
838
822
  if (featureEnabled && productInfo.product.baseSku) {
839
- cartQty = await getBaseSkuCartQuantity(productInfo.product.baseSku)
823
+ cartQty = await getBaseSkuCartQuantity(productInfo.product.baseSku)
840
824
  }
841
825
  const qualCnt = qual ? qual.quantity : 0;
842
826
 
@@ -952,7 +952,7 @@ const getCartType = () => {
952
952
  const nsConfig = ConfigService.getMarketConfig();
953
953
  let cartType = null;
954
954
 
955
- if (nsConfig.usePersistentCart && !window.location.pathname.startsWith("/content/login/corporate")) {
955
+ if (!window.location.pathname.startsWith("/content/login/corporate")) {
956
956
  const context = ShoppingContext.getShoppingContext();
957
957
 
958
958
  if (context) {
@@ -3,7 +3,6 @@ import {PriceType, Product} from '@nuskin/ns-product-lib';
3
3
  import {ConfigService, RunConfigService, util, events, BrowserDetection} from '@nuskin/ns-util';
4
4
  import {UserService, AccountManager} from '@nuskin/ns-account';
5
5
  import ProductStatusService from '../product/ProductStatusService.js';
6
- import FireBaseProductService from '../firebase/fireBaseProductService.js';
7
6
  import _ from 'lodash';
8
7
 
9
8
  let ProductService = function() {
@@ -14,21 +13,17 @@ let ProductService = function() {
14
13
  // ---------------------------------------------
15
14
  let publicMethods = {
16
15
  getProductByTerm: function(term, priceType, country, language, callbackFn) {
17
- if (ConfigService.getMarketConfig().useFirebaseProducts){
18
- FireBaseProductService.getProductsBySearchTerm(term, country, language, callbackFn);
19
- } else {
20
- let url = getCloudSearchUrl(term, priceType, country, language);
21
-
22
- try {
23
- $.ajax({
24
- type: "GET",
25
- url: url,
26
- success: productListCallback(callbackFn),
27
- error: failedCallback(callbackFn, url, term, events.errors.PRODUCT_LOOKUP)
28
- });
29
- } catch (e) {
30
- return null;
31
- }
16
+ let url = getCloudSearchUrl(term, priceType, country, language);
17
+
18
+ try {
19
+ $.ajax({
20
+ type: "GET",
21
+ url: url,
22
+ success: productListCallback(callbackFn),
23
+ error: failedCallback(callbackFn, url, term, events.errors.PRODUCT_LOOKUP)
24
+ });
25
+ } catch (e) {
26
+ return null;
32
27
  }
33
28
  },
34
29
 
@@ -172,10 +167,6 @@ let ProductService = function() {
172
167
  query = query.replace('{countryCd}', country);
173
168
  query = query.replace('{language}', language);
174
169
  query = query.replace('{priceType}', priceType);
175
- // if SEAShoppe add param to url
176
- if (marketConfig.checkout.enableSEAShoppe) {
177
- query += "/SEAShoppe";
178
- }
179
170
  return query;
180
171
  }
181
172
 
@@ -184,32 +184,30 @@ const populateShipping = (order, salesOrder) => {
184
184
  }]
185
185
  }
186
186
 
187
- if (!nsConfig.checkout.skipShippingAddress) {
188
- shippingParty.ShippingAddress = {
189
- Name: order.selectedAddress.shippingAddressName,
190
- Address: {
191
- Street1: order.selectedAddress.shippingAddress1,
192
- Street2: order.selectedAddress.shippingAddress2,
193
- City: order.selectedAddress.shippingCity,
194
- District: order.selectedAddress.shippingCounty,
195
- Region: (!ConfigService.getMarketConfig().checkout.doNotSendRegion &&
196
- (!Array.isArray(order.selectedAddress.shippingState) ||
197
- order.selectedAddress.shippingState.length > 0))
198
- ? order.selectedAddress.shippingState
199
- : null,
200
- PostalCode: order.selectedAddress.shippingPostalCode,
201
- CountryCode: order.selectedAddress.shippingCountry
202
- },
203
- Contact: [],
204
- Instructions: order.selectedAddress.shippingInstructions
205
- };
206
- shippingParty.Custom = [{
207
- Type: "ADDRESS",
208
- Key: "TYPE",
209
- Value: order.selectedAddress.addressType
210
- }];
211
- addContactInfo(shippingParty.ShippingAddress.Contact, order.selectedAddress);
212
- }
187
+ shippingParty.ShippingAddress = {
188
+ Name: order.selectedAddress.shippingAddressName,
189
+ Address: {
190
+ Street1: order.selectedAddress.shippingAddress1,
191
+ Street2: order.selectedAddress.shippingAddress2,
192
+ City: order.selectedAddress.shippingCity,
193
+ District: order.selectedAddress.shippingCounty,
194
+ Region: (!ConfigService.getMarketConfig().checkout.doNotSendRegion &&
195
+ (!Array.isArray(order.selectedAddress.shippingState) ||
196
+ order.selectedAddress.shippingState.length > 0))
197
+ ? order.selectedAddress.shippingState
198
+ : null,
199
+ PostalCode: order.selectedAddress.shippingPostalCode,
200
+ CountryCode: order.selectedAddress.shippingCountry
201
+ },
202
+ Contact: [],
203
+ Instructions: order.selectedAddress.shippingInstructions
204
+ };
205
+ shippingParty.Custom = [{
206
+ Type: "ADDRESS",
207
+ Key: "TYPE",
208
+ Value: order.selectedAddress.addressType
209
+ }];
210
+ addContactInfo(shippingParty.ShippingAddress.Contact, order.selectedAddress);
213
211
 
214
212
  salesOrder.Shipping.ShippingParty.push(shippingParty);
215
213
 
@@ -10,10 +10,8 @@ import axios from 'axios';
10
10
 
11
11
  // Service URI Paths
12
12
  const PMNT_BASE_LEGACY = '/shop-service/api/v2/payment';
13
- const PMNT_PATH_LEGACY = PMNT_BASE_LEGACY + '/saved';
14
13
  const PMNT_PATH_AWS_V1 = '/paymentprofile/v1';
15
14
  const PMNT_PATH_AWS_V2 = '/paymentprofile/v2';
16
- const PMNT_TYPES_PATH_LEGACY = PMNT_BASE_LEGACY + '/typesallowed';
17
15
  const PMNT_TYPES_PATH_AWS = '/paymentOptions/v1';
18
16
  const EXT_PMNT_PATH_LEGACY = '/external-payment/api/v1';
19
17
 
@@ -28,15 +26,11 @@ const getLegacyBaseURL = () => ConfigService.getMarketConfig().siteUrl;
28
26
 
29
27
  const getAWSBaseURL = () => ConfigService.getMarketConfig().awsUrl;
30
28
 
31
- const isUsingAWS = () => !!ConfigService.getMarketConfig().useAwsPaymentProfileService;
29
+ const getPmntURLV1 = () => getAWSBaseURL() + PMNT_PATH_AWS_V1;
32
30
 
33
- const getBaseURL = () => isUsingAWS() ? getAWSBaseURL() : getLegacyBaseURL();
31
+ const getPmntURLV2 = () => getAWSBaseURL() + PMNT_PATH_AWS_V2;
34
32
 
35
- const getPmntURLV1 = () => getBaseURL() + (isUsingAWS() ? PMNT_PATH_AWS_V1 : PMNT_PATH_LEGACY);
36
-
37
- const getPmntURLV2 = () => getBaseURL() + (isUsingAWS() ? PMNT_PATH_AWS_V2 : PMNT_PATH_LEGACY);
38
-
39
- const getPmntTypeURL = () => getBaseURL() + (isUsingAWS() ? PMNT_TYPES_PATH_AWS : PMNT_TYPES_PATH_LEGACY);
33
+ const getPmntTypeURL = () => getAWSBaseURL() + PMNT_TYPES_PATH_AWS;
40
34
 
41
35
  const getExtPmntURL = () => getLegacyBaseURL() + EXT_PMNT_PATH_LEGACY;
42
36
 
@@ -60,7 +60,9 @@ let PaymentType = {
60
60
  CENC: 125,
61
61
  IDMIR: 128, // MIR card for Russia
62
62
  AMIN: 129,
63
- CBLU: 132 // Carte Bleue
63
+ CBLU: 132, // Carte Bleue
64
+ '2C2P': 133,
65
+ SIMV: 134
64
66
  };
65
67
 
66
68
  PaymentType.credit = [
@@ -82,7 +84,8 @@ PaymentType.credit = [
82
84
  PaymentType.VISD,
83
85
  PaymentType.MCD,
84
86
  PaymentType.IDMIR,
85
- PaymentType.CBLU
87
+ PaymentType.CBLU,
88
+ PaymentType.SIMV
86
89
  ];
87
90
 
88
91
 
@@ -5,7 +5,6 @@ import axios from 'axios';
5
5
 
6
6
  let baseUrl;
7
7
  let awsUrl;
8
- const SHIPPING_PATH = '/shop-service/api/v2/shipping/address/';
9
8
  const SHIP_DAYS_ROOT_PATH = '/shop-service/api/v2/ship-days';
10
9
  const AWS_SHIPPING_PATH = '/shippingprofile/v1/';
11
10
  const USER = UserService.getUser();
@@ -157,7 +156,7 @@ async function getVNRegionList () {
157
156
  */
158
157
  async function getListOfCitiesFromPostalCode (country, zip) {
159
158
  const {
160
- awsUrl,
159
+ awsUrl,
161
160
  checkout: { postalCodeServiceUrl }
162
161
  } = ConfigService.getMarketConfig();
163
162
 
@@ -169,14 +168,14 @@ async function getListOfCitiesFromPostalCode (country, zip) {
169
168
  .replace(/:cntry/g, country)
170
169
  .replace(/:code/g, zip);
171
170
  }
172
-
171
+
173
172
  const results = await fetch(url, {
174
173
  method: 'GET',
175
174
  credentials: 'omit',
176
175
  headers: ServiceUtils.getHeaders()
177
176
  })
178
177
  .then(ServiceUtils.transformFetchResponse);
179
-
178
+
180
179
  return (country === 'MX') ? results.zzipRecords : results;
181
180
  }
182
181
 
@@ -191,18 +190,11 @@ async function getListOfCitiesFromPostalCode (country, zip) {
191
190
  */
192
191
  function getUrl(queryParams, pathParam = '') {
193
192
  let url;
194
- if (ConfigService.getMarketConfig().useAwsShippingProfileService) {
195
- if (!awsUrl) {
196
- awsUrl = ConfigService.getMarketConfig().awsUrl;
197
- }
198
- delete queryParams.eid;
199
- url = `${awsUrl}${AWS_SHIPPING_PATH}${pathParam}?${UrlService.toQueryString(queryParams)}`;
200
- } else {
201
- if (!baseUrl) {
202
- baseUrl = ConfigService.getMarketConfig().siteUrl;
203
- }
204
- url = `${baseUrl}${SHIPPING_PATH}${pathParam}?${UrlService.toQueryString(queryParams)}`;
193
+ if (!awsUrl) {
194
+ awsUrl = ConfigService.getMarketConfig().awsUrl;
205
195
  }
196
+ delete queryParams.eid;
197
+ url = `${awsUrl}${AWS_SHIPPING_PATH}${pathParam}?${UrlService.toQueryString(queryParams)}`;
206
198
  return url
207
199
  }
208
200
 
@@ -216,9 +208,7 @@ function getHeaders(eid) {
216
208
  let retHeader;
217
209
 
218
210
  headers = headers || ServiceUtils.getHeaders();
219
- ConfigService.getMarketConfig().useAwsShippingProfileService ?
220
- retHeader = Object.assign({Authorization: `JWT ${eid}`, 'content-type': 'application/json'}, headers) :
221
- retHeader = Object.assign({'content-type': 'application/json'}, headers);
211
+ retHeader = Object.assign({Authorization: `JWT ${eid}`, 'content-type': 'application/json'}, headers);
222
212
 
223
213
  return retHeader;
224
214
  }
package/src/shop.js CHANGED
@@ -20,12 +20,6 @@ export {default as ErrorMessageCookieService} from './error/errorMessageCookieSe
20
20
  export {default as ErrorMessageList} from './error/errorMessageList.js';
21
21
  export {default as ErrorMessage} from './error/errorMessage.js';
22
22
  export {default as FavoritesService} from './favorites/FavoritesService';
23
- export {default as FirebaseProduct} from './firebase/firebaseProduct.js';
24
- export {default as FirebaseProductDetail} from './firebase/firebaseProductDetail.js';
25
- export {default as FireBaseProductService} from './firebase/fireBaseProductService.js';
26
- export {default as FirebaseProductParser} from './firebase/firebaseProductParser.js';
27
- export {default as FirebaseProductCallbackUtil} from './firebase/firebaseProductCallbackUtil.js';
28
- export {default as FirebaseHealthUtil} from './firebase/firebaseHealthUtil.js';
29
23
  export {default as LtoUtils} from './ltoUtils.js';
30
24
  export {default as LuhnCheck} from './payment/luhnCheck.js';
31
25
  export {default as newShop} from './newShop.js';