@nuskin/ns-shop 7.7.0-pa-87.1 → 7.7.0-pa-87.3
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
package/src/cart/cartService.js
CHANGED
|
@@ -6,6 +6,7 @@ import {AdrService, Product, ScanCard, CurrencyService} from '@nuskin/ns-shop';
|
|
|
6
6
|
import {UserService, AccountManager} from '@nuskin/ns-account';
|
|
7
7
|
import ProductService from './productService';
|
|
8
8
|
import Cart from './cart.js';
|
|
9
|
+
import OrderType from '../order/orderType.js';
|
|
9
10
|
import AdrEditService from '../adr/AdrEditService.js';
|
|
10
11
|
import QualificationService from '@nuskin/exclusive-offer-sdk'
|
|
11
12
|
import {ProductStatus} from '@nuskin/ns-product-lib';
|
|
@@ -300,17 +301,24 @@ function hasPreviewItems() {
|
|
|
300
301
|
return _getCart().hasPreviewItems();
|
|
301
302
|
}
|
|
302
303
|
|
|
303
|
-
function
|
|
304
|
+
function _getItemsByOrderType(orderType) {
|
|
305
|
+
if (orderType.SHIP_IMMEDIATE) return getItemData({cartItems: true});
|
|
306
|
+
else if (orderType == OrderType.ADR_CREATE) return getItemData({cartAdrItems: true});
|
|
307
|
+
else return getItemData({cartOrderItems: true});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function hasDangerousGoods(orderType) {
|
|
304
311
|
let retVal = false;
|
|
305
|
-
|
|
312
|
+
_getItemsByOrderType(orderType).forEach((item) => {
|
|
306
313
|
retVal = retVal || item.product.dangerousGoods;
|
|
307
314
|
});
|
|
308
315
|
return retVal;
|
|
309
316
|
}
|
|
310
317
|
|
|
311
|
-
function getCartWeight() {
|
|
318
|
+
function getCartWeight(orderType) {
|
|
312
319
|
let retVal = 0.0;
|
|
313
|
-
|
|
320
|
+
|
|
321
|
+
_getItemsByOrderType(orderType).forEach((item) => {
|
|
314
322
|
retVal += item.qty * (item.product.grossWeight || 0.0);
|
|
315
323
|
});
|
|
316
324
|
return retVal;
|
|
@@ -1129,11 +1129,11 @@ const populateSalesOrder = (action, adr) => {
|
|
|
1129
1129
|
return salesOrder;
|
|
1130
1130
|
};
|
|
1131
1131
|
|
|
1132
|
-
const getShipMethods = async (salesOrderDetail) => {
|
|
1132
|
+
const getShipMethods = async (salesOrderDetail, orderType) => {
|
|
1133
1133
|
let shipMethods;
|
|
1134
1134
|
const useShipMethodsApi = getCachedConfigField('useShipMethodsApi');
|
|
1135
1135
|
if (useShipMethodsApi) {
|
|
1136
|
-
await PickupUtil.loadShipMethods(Order.fromSalesOrderRequest(populateSalesOrder('SIMULATE')));
|
|
1136
|
+
await PickupUtil.loadShipMethods(Order.fromSalesOrderRequest(populateSalesOrder('SIMULATE')), orderType);
|
|
1137
1137
|
shipMethods = await PickupUtil.getShipMethods();
|
|
1138
1138
|
} else {
|
|
1139
1139
|
shipMethods = salesOrderDetail.ShippingAvailableMethods
|
|
@@ -1164,7 +1164,7 @@ const toOrder = async (salesOrderDetail, adr, createResponse) => {
|
|
|
1164
1164
|
|
|
1165
1165
|
const useShipMethodsApi = getCachedConfigField('useShipMethodsApi');
|
|
1166
1166
|
if (useShipMethodsApi || salesOrderDetail.ShippingAvailableMethods && salesOrderDetail.ShippingAvailableMethods.length > 0) {
|
|
1167
|
-
const shipMethods = await getShipMethods(salesOrderDetail);
|
|
1167
|
+
const shipMethods = await getShipMethods(salesOrderDetail, order.orderType);
|
|
1168
1168
|
order.shippingAvailableMethods = sortShippingAvailableMethods(shipMethods);
|
|
1169
1169
|
|
|
1170
1170
|
setShippingAvailableMethodsPickupInfo(order.shippingAvailableMethods);
|
|
@@ -78,7 +78,7 @@ const _initOrder = () => {
|
|
|
78
78
|
if (getCachedConfigField('useShipMethodsApi')) {
|
|
79
79
|
const csDefaultCode = getCachedConfigField('defaultShipMethod');
|
|
80
80
|
if (csDefaultCode) {
|
|
81
|
-
result.selectedShippingMethod = {Code: csDefaultCode};
|
|
81
|
+
result.selectedShippingMethod = {Code: csDefaultCode, PickUpLocation: ''};
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -196,7 +196,7 @@ let PickupUtil = function() {
|
|
|
196
196
|
return same
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
function loadShipMethods(order) {
|
|
199
|
+
function loadShipMethods(order, orderType) {
|
|
200
200
|
const {metapackMarket} = getCachedConfiguration('Checkout');
|
|
201
201
|
|
|
202
202
|
if (metapackMarket) {
|
|
@@ -204,8 +204,8 @@ let PickupUtil = function() {
|
|
|
204
204
|
const payload = {
|
|
205
205
|
order,
|
|
206
206
|
orderValue: getOrderValue(),
|
|
207
|
-
dangerousGoods: CartService.hasDangerousGoods(),
|
|
208
|
-
weight: CartService.getCartWeight(),
|
|
207
|
+
dangerousGoods: CartService.hasDangerousGoods(orderType),
|
|
208
|
+
weight: CartService.getCartWeight(orderType),
|
|
209
209
|
language: runConfig.language,
|
|
210
210
|
country: runConfig.country
|
|
211
211
|
};
|