@nuskin/ns-shop 7.5.4-td-1017.2.1 → 7.5.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.5.4
|
|
3
|
+
"version": "7.5.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": {
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
43
|
+
"@nuskin/ns-account": "5.13.0",
|
|
44
44
|
"@nuskin/ns-jsanalyzer": "1.0.1",
|
|
45
|
-
"@nuskin/ns-product": "3.51.
|
|
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,79 @@ 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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
221
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
).then((results) => {
|
|
223
|
+
sessionStorage.setItem('shipping', JSON.stringify({
|
|
224
|
+
payload,
|
|
225
|
+
shipMethods: results.data.shipMethods,
|
|
226
|
+
pickUpPoints: results.data.pickupPoints
|
|
227
|
+
}))
|
|
228
|
+
}).catch((err) => {
|
|
229
|
+
console.log(err);
|
|
230
|
+
sessionStorage.setItem('shipping', JSON.stringify({payload: {}, shipMethods: [], pickUpPoints: []}));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
199
233
|
}
|
|
200
234
|
}
|
|
201
235
|
|
|
202
236
|
// if the calling code knows that loadShipMethods has finished then this
|
|
203
237
|
// function can be called directly if the calling function is not async.
|
|
204
238
|
function getStoredShipMethods() {
|
|
205
|
-
const
|
|
206
|
-
return
|
|
239
|
+
const shipping = sessionStorage.getItem('shipping');
|
|
240
|
+
return shipping ? JSON.parse(shipping).shipMethods : [];
|
|
207
241
|
}
|
|
208
242
|
|
|
209
243
|
async function getShipMethods() {
|
|
@@ -215,8 +249,8 @@ let PickupUtil = function() {
|
|
|
215
249
|
async function getPickupPoints() {
|
|
216
250
|
await promise;
|
|
217
251
|
|
|
218
|
-
const
|
|
219
|
-
return
|
|
252
|
+
const shipping = sessionStorage.getItem('shipping');
|
|
253
|
+
return shipping ? JSON.parse(shipping).pickUpPoints : [];
|
|
220
254
|
}
|
|
221
255
|
|
|
222
256
|
return {
|