@nuskin/ns-shop 7.3.0-mdigi-897.3 → 7.3.0-mdigi-897.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 +1 -1
- package/src/order/order.js +11 -0
- package/src/order/orderAdapter.js +32 -10
- package/src/shipping/pickupUtil.js +14 -5
package/package.json
CHANGED
package/src/order/order.js
CHANGED
|
@@ -29,6 +29,7 @@ newShop.Order = function(orderData){
|
|
|
29
29
|
|
|
30
30
|
let selectedAddress;
|
|
31
31
|
let selectedShippingMethod;
|
|
32
|
+
let simulatedShippingMethod = {};
|
|
32
33
|
let shippingAvailableMethods;
|
|
33
34
|
let availableAddressTypes;
|
|
34
35
|
let selectedPayment;
|
|
@@ -110,6 +111,7 @@ newShop.Order = function(orderData){
|
|
|
110
111
|
simulateWithoutShipping = orderData.simulateWithoutShipping;
|
|
111
112
|
externalPayment = orderData.externalPayment;
|
|
112
113
|
selectedShippingMethod = orderData.selectedShippingMethod;
|
|
114
|
+
simulatedShippingMethod = orderData.simulatedShippingMethod || {};
|
|
113
115
|
shippingAvailableMethods = orderData.shippingAvailableMethods;
|
|
114
116
|
availableAddressTypes = orderData.availableAddressTypes;
|
|
115
117
|
errorResponseInfo = orderData.errorResponseInfo;
|
|
@@ -263,6 +265,7 @@ newShop.Order = function(orderData){
|
|
|
263
265
|
order.simulateWithoutShipping = simulateWithoutShipping;
|
|
264
266
|
order.externalPayment = externalPayment;
|
|
265
267
|
order.selectedShippingMethod = selectedShippingMethod;
|
|
268
|
+
order.simulatedShippingMethod = simulatedShippingMethod || {};
|
|
266
269
|
order.shippingAvailableMethods = shippingAvailableMethods;
|
|
267
270
|
order.availableAddressTypes = availableAddressTypes;
|
|
268
271
|
order.errorResponseInfo = errorResponseInfo;
|
|
@@ -468,6 +471,14 @@ newShop.Order = function(orderData){
|
|
|
468
471
|
selectedShippingMethod = _selectedShippingMethod;
|
|
469
472
|
}
|
|
470
473
|
},
|
|
474
|
+
simulatedShippingMethod: {
|
|
475
|
+
get: function() {
|
|
476
|
+
return simulatedShippingMethod;
|
|
477
|
+
},
|
|
478
|
+
set: function(_simulatedShippingMethod) {
|
|
479
|
+
simulatedShippingMethod = _simulatedShippingMethod;
|
|
480
|
+
}
|
|
481
|
+
},
|
|
471
482
|
shippingAvailableMethods: {
|
|
472
483
|
get: function() {
|
|
473
484
|
return shippingAvailableMethods;
|
|
@@ -137,7 +137,7 @@ const populateItem = (order, salesOrder, shipImmediate, includeSapItems) => {
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
const populateAttribution = (salesOrder) => {
|
|
140
|
-
const sponsorId = util.getSponsorId();
|
|
140
|
+
const sponsorId = util.getSponsorId();
|
|
141
141
|
const enableGuestCheckout = getCachedConfigField('enableGuestCheckout');
|
|
142
142
|
|
|
143
143
|
if (sponsorId) {
|
|
@@ -164,12 +164,29 @@ const populateAttribution = (salesOrder) => {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
const getDefaultShipCode = (osmc) => {
|
|
168
|
+
let defaultCode = osmc;
|
|
169
|
+
const useShipMethodsApi = getCachedConfigField('useShipMethodsApi')
|
|
170
|
+
if (useShipMethodsApi) {
|
|
171
|
+
const csDefaultCode = getCachedConfigField('defaultShipMethod');
|
|
172
|
+
const shipMethods = PickupUtil.getStoredShipMethods();
|
|
173
|
+
const firstSm = shipMethods.length > 0 ? shipMethods[0].Code : '';
|
|
174
|
+
const defaultShipMethod = shipMethods.find((sm) => sm.Code === osmc);
|
|
175
|
+
if (!defaultShipMethod) {
|
|
176
|
+
defaultCode = shipMethods.find((sm) => sm.Code === csDefaultCode) ? csDefaultCode : firstSm;
|
|
177
|
+
} else {
|
|
178
|
+
defaultCode = defaultShipMethod.Code;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return defaultCode;
|
|
183
|
+
};
|
|
184
|
+
|
|
167
185
|
const populateShipping = (order, salesOrder) => {
|
|
168
186
|
const user = UserService.getUser();
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const code = method ? method.Code : defaultCode;
|
|
187
|
+
const orderShipMethod = order.selectedShippingMethod;
|
|
188
|
+
const orderShipMethodCode = orderShipMethod ? orderShipMethod.Code : null;
|
|
189
|
+
const code = getDefaultShipCode(orderShipMethodCode);
|
|
173
190
|
|
|
174
191
|
//code = (util.countryCode === 'ZA') ? (order.selectedAddress.addressType == "home" ? "ZH" : "ST") : code;
|
|
175
192
|
|
|
@@ -311,8 +328,8 @@ const populateShipping = (order, salesOrder) => {
|
|
|
311
328
|
salesOrder.Shipping.ShippingParty.push(billTo);
|
|
312
329
|
}
|
|
313
330
|
|
|
314
|
-
if (
|
|
315
|
-
salesOrder.Shipping.ShippingMethod.PickUpLocation =
|
|
331
|
+
if (orderShipMethod && orderShipMethod.PickUpLocation) {
|
|
332
|
+
salesOrder.Shipping.ShippingMethod.PickUpLocation = orderShipMethod.PickUpLocation;
|
|
316
333
|
}
|
|
317
334
|
if (order.selectedDeliveryTimeSlot) {
|
|
318
335
|
salesOrder.timeSlotId = order.selectedDeliveryTimeSlot.id;
|
|
@@ -480,10 +497,10 @@ const populateCategory = (salesOrder) => {
|
|
|
480
497
|
} else if (util.getSponsorId()) {
|
|
481
498
|
// affiliates don't use a subdomain. So if we have a sponsor and it isn't a pitch then we consider it a storefront
|
|
482
499
|
salesOrder.Category = "STOREFRONT";
|
|
483
|
-
} else if(utmInfo
|
|
484
|
-
if (utmInfo
|
|
500
|
+
} else if(utmInfo && utmInfo.utm_medium){
|
|
501
|
+
if (utmInfo && utmInfo.utm_medium.includes('paidsearch')) {
|
|
485
502
|
salesOrder.Category = 'PAIDSEARCH';
|
|
486
|
-
} else if (utmInfo
|
|
503
|
+
} else if (utmInfo && utmInfo.utm_medium.includes('paidsocial')) {
|
|
487
504
|
salesOrder.Category = 'PAIDAD';
|
|
488
505
|
} else {
|
|
489
506
|
salesOrder.Category = 'WEB';
|
|
@@ -1126,6 +1143,11 @@ const toOrder = async (salesOrderDetail, adr, createResponse) => {
|
|
|
1126
1143
|
if (useShipMethodsApi || salesOrderDetail.ShippingAvailableMethods && salesOrderDetail.ShippingAvailableMethods.length > 0) {
|
|
1127
1144
|
const shipMethods = useShipMethodsApi ? await pickupUtil.getShipMethods() : salesOrderDetail.ShippingAvailableMethods;
|
|
1128
1145
|
order.shippingAvailableMethods = sortShippingAvailableMethods(shipMethods);
|
|
1146
|
+
order.simulatedShippingMethod =
|
|
1147
|
+
order.shippingAvailableMethods.find(
|
|
1148
|
+
(sam) => sam.Code === salesOrderDetail.Shipping.ShippingMethod.Code
|
|
1149
|
+
) || order.shippingAvailableMethods[0];
|
|
1150
|
+
|
|
1129
1151
|
setShippingAvailableMethodsPickupInfo(order.shippingAvailableMethods);
|
|
1130
1152
|
setSelectedShipMethod(order, salesOrderDetail.Shipping.ShippingMethod);
|
|
1131
1153
|
// When an order or ADR is created. The response from the create call is missing the list of pickup locations
|
|
@@ -5,7 +5,7 @@ import {OrderManager, CartService, OrderType, OrderAdapter} from '../shop';
|
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
|
|
7
7
|
const SHIP_METHODS = 'shipMethods';
|
|
8
|
-
const
|
|
8
|
+
const PICK_UP_POINTS = 'pickUpPoints';
|
|
9
9
|
|
|
10
10
|
let PickupUtil = function() {
|
|
11
11
|
'use strict';
|
|
@@ -192,25 +192,33 @@ let PickupUtil = function() {
|
|
|
192
192
|
}
|
|
193
193
|
).then((results) => {
|
|
194
194
|
sessionStorage.setItem(SHIP_METHODS, JSON.stringify(results.data.shipMethods))
|
|
195
|
-
sessionStorage.setItem(
|
|
195
|
+
sessionStorage.setItem(PICK_UP_POINTS, JSON.stringify(results.data.pickupPoints))
|
|
196
196
|
}).catch((err) => {
|
|
197
197
|
console.log(err);
|
|
198
198
|
sessionStorage.setItem(SHIP_METHODS, JSON.stringify([]));
|
|
199
|
-
sessionStorage.setItem(
|
|
199
|
+
sessionStorage.setItem(PICK_UP_POINTS, JSON.stringify([]));
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
// if the calling code knows that loadShipMethods has finished then this
|
|
205
|
+
// function can be called directly if the calling function is not async.
|
|
206
|
+
function getStoredShipMethods() {
|
|
207
|
+
const shipMethods = sessionStorage.getItem(SHIP_METHODS);
|
|
208
|
+
return shipMethods ? JSON.parse(shipMethods) : [];
|
|
209
|
+
}
|
|
210
|
+
|
|
204
211
|
async function getShipMethods() {
|
|
205
212
|
await promise;
|
|
206
213
|
|
|
207
|
-
return
|
|
214
|
+
return getStoredShipMethods();
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
async function getPickupPoints() {
|
|
211
218
|
await promise;
|
|
212
219
|
|
|
213
|
-
|
|
220
|
+
const pups = sessionStorage.getItem(PICK_UP_POINTS);
|
|
221
|
+
return pups ? JSON.parse(pups) : [];
|
|
214
222
|
}
|
|
215
223
|
|
|
216
224
|
return {
|
|
@@ -221,6 +229,7 @@ let PickupUtil = function() {
|
|
|
221
229
|
markers: generateMarkers,
|
|
222
230
|
loadShipMethods,
|
|
223
231
|
getShipMethods,
|
|
232
|
+
getStoredShipMethods,
|
|
224
233
|
getPickupPoints
|
|
225
234
|
}
|
|
226
235
|
}();
|