@nuskin/ns-shop 7.5.4-td-1017.2.1 → 7.5.5-pa-64.1

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.5.4-td-1017.2.1",
3
+ "version": "7.5.5-pa-64.1",
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,10 +26,10 @@
26
26
  "@nuskin/ns-common-lib": "1.4.8",
27
27
  "@nuskin/ns-feature-flags": "1.5.0",
28
28
  "@nuskin/ns-loyalty-web": "1.5.7",
29
- "@nuskin/ns-product-lib": "2.20.1-td-1017.1",
29
+ "@nuskin/ns-product-lib": "2.20.0",
30
30
  "@nuskin/nuskinjquery": "2.3.1",
31
31
  "@nuskin/order-model": "3.1.3",
32
- "@nuskin/product-lib": "2.4.1-td-1017.1",
32
+ "@nuskin/product-lib": "2.4.0",
33
33
  "axios": "1.8.3",
34
34
  "decimal.js": "10.4.3",
35
35
  "jp-conversion": "0.0.7",
@@ -40,9 +40,9 @@
40
40
  "@babel/preset-env": "^7.23.8",
41
41
  "@nuskin/configuration-sdk": "3.0.0",
42
42
  "@nuskin/exclusive-offer-sdk": "1.4.1",
43
- "@nuskin/ns-account": "5.13.1-td-1017.1",
43
+ "@nuskin/ns-account": "5.13.0",
44
44
  "@nuskin/ns-jsanalyzer": "1.0.1",
45
- "@nuskin/ns-product": "3.51.1-td-1017.1",
45
+ "@nuskin/ns-product": "3.51.0",
46
46
  "@nuskin/ns-util": "4.7.2",
47
47
  "axios-mock-adapter": "1.22.0",
48
48
  "babel-cli": "6.26.0",
@@ -461,8 +461,7 @@ function _assembleAdrProperties(requestData, options) {
461
461
  isBackOrdered: requestData.skus && requestData.skus[requestData.skus.length - 1].backOrdered || false,
462
462
  imageURL: options.product.fullImage || '',
463
463
  name: options.product.title,
464
- productId: options.product.equinoxProductId || '',
465
- productionBom: options.product && options.product.properties && options.product.properties.productionBom || false
464
+ productId: options.product.equinoxProductId || ''
466
465
  };
467
466
  }
468
467
 
@@ -4,9 +4,6 @@ import {RunConfigService} from '@nuskin/ns-util';
4
4
  import {OrderManager, CartService, OrderType, OrderAdapter} from '../shop';
5
5
  import axios from 'axios';
6
6
 
7
- const SHIP_METHODS = 'shipMethods';
8
- const PICK_UP_POINTS = 'pickUpPoints';
9
-
10
7
  let PickupUtil = function() {
11
8
  'use strict';
12
9
  const SERVICE_GROUP = 'SERVICE_GROUP',
@@ -168,42 +165,80 @@ let PickupUtil = function() {
168
165
  }
169
166
  }
170
167
 
168
+ function getShipToData(order) {
169
+ const shippingParties = (order && order.shipping && order.shipping.shippingParties) || [];
170
+ const shipTo = shippingParties.find((sp) => sp.type === 'SHIP_TO');
171
+ return shipTo ? {
172
+ country: shipTo.shippingAddress.address.countryCode,
173
+ postalCode: shipTo.shippingAddress.address.postalCode,
174
+ line1: `${shipTo.shippingAddress.address.street1}, ${shipTo.shippingAddress.address.city}`,
175
+ line2: shipTo.shippingAddress.address.street2,
176
+ city: shipTo.shippingAddress.address.city
177
+ } : {};
178
+ }
179
+
180
+ function samePayload(payload) {
181
+ let same = false;
182
+ const shipping = sessionStorage.getItem('shipping');
183
+
184
+ if (shipping) {
185
+ const storedPayload = JSON.parse(shipping).payload;
186
+ const shipData = getShipToData(payload.order);
187
+ const storedShipData = getShipToData(storedPayload.order);
188
+ same = payload.country === storedPayload.country &&
189
+ payload.dangerousGoods === storedPayload.dangerousGoods &&
190
+ payload.orderValue === storedPayload.orderValue &&
191
+ shipData.country === storedShipData.country &&
192
+ shipData.postalCode === storedShipData.postalCode &&
193
+ shipData.line1 === storedShipData.line1 &&
194
+ shipData.line2 === storedShipData.line2 &&
195
+ shipData.city === storedShipData.city
196
+ }
197
+ return same
198
+ }
199
+
171
200
  function loadShipMethods() {
172
201
  const order = Order.fromSalesOrderRequest(OrderAdapter.populateSalesOrder('SIMULATE'));
173
202
  const {metapackMarket} = getCachedConfiguration('Checkout');
174
203
 
175
204
  if (metapackMarket) {
176
205
  const runConfig = RunConfigService.getRunConfig();
177
- promise = axios.post(
178
- getUrl(),
179
- {
180
- order,
181
- orderValue: getOrderValue(),
182
- dangerousGoods: CartService.hasDangerousGoods(),
183
- language: runConfig.language,
184
- country: runConfig.country
185
- },
186
- {
187
- headers: {
188
- 'Content-Type': 'application/json; charset=UTF-8'
206
+ const payload = {
207
+ order,
208
+ orderValue: getOrderValue(),
209
+ dangerousGoods: CartService.hasDangerousGoods(),
210
+ language: runConfig.language,
211
+ country: runConfig.country
212
+ };
213
+ if (!samePayload(payload)) {
214
+ promise = axios.post(
215
+ getUrl(),
216
+ payload,
217
+ {
218
+ headers: {
219
+ 'Content-Type': 'application/json; charset=UTF-8'
220
+ },
221
+ timeout: 29000
189
222
  }
190
- }
191
- ).then((results) => {
192
- sessionStorage.setItem(SHIP_METHODS, JSON.stringify(results.data.shipMethods))
193
- sessionStorage.setItem(PICK_UP_POINTS, JSON.stringify(results.data.pickupPoints))
194
- }).catch((err) => {
195
- console.log(err);
196
- sessionStorage.setItem(SHIP_METHODS, JSON.stringify([]));
197
- sessionStorage.setItem(PICK_UP_POINTS, JSON.stringify([]));
198
- });
223
+ ).then((results) => {
224
+ sessionStorage.setItem('shipping', JSON.stringify({
225
+ payload,
226
+ shipMethods: results.data.shipMethods,
227
+ pickUpPoints: results.data.pickupPoints
228
+ }))
229
+ }).catch((err) => {
230
+ console.log(err);
231
+ sessionStorage.setItem('shipping', JSON.stringify({payload: {}, shipMethods: [], pickUpPoints: []}));
232
+ });
233
+ }
199
234
  }
200
235
  }
201
236
 
202
237
  // if the calling code knows that loadShipMethods has finished then this
203
238
  // function can be called directly if the calling function is not async.
204
239
  function getStoredShipMethods() {
205
- const shipMethods = sessionStorage.getItem(SHIP_METHODS);
206
- return shipMethods ? JSON.parse(shipMethods) : [];
240
+ const shipping = sessionStorage.getItem('shipping');
241
+ return shipping ? JSON.parse(shipping).shipMethods : [];
207
242
  }
208
243
 
209
244
  async function getShipMethods() {
@@ -215,8 +250,8 @@ let PickupUtil = function() {
215
250
  async function getPickupPoints() {
216
251
  await promise;
217
252
 
218
- const pups = sessionStorage.getItem(PICK_UP_POINTS);
219
- return pups ? JSON.parse(pups) : [];
253
+ const shipping = sessionStorage.getItem('shipping');
254
+ return shipping ? JSON.parse(shipping).pickUpPoints : [];
220
255
  }
221
256
 
222
257
  return {