@nuskin/ns-shop 5.14.15 → 5.15.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
package/src/cart/cart.js
CHANGED
|
@@ -2,7 +2,7 @@ import newShop from '../newShop';
|
|
|
2
2
|
import CartItem from './cartItem.js';
|
|
3
3
|
import ShopContext from '../shopContext.js';
|
|
4
4
|
import {AccountManager, UserService} from '@nuskin/ns-account';
|
|
5
|
-
import {
|
|
5
|
+
import {events, storage, NUSAnalytics, PersonalOfferStorageService, ConfigService} from '@nuskin/ns-util';
|
|
6
6
|
import webLoyalty from '@nuskin/ns-loyalty-web';
|
|
7
7
|
import {PriceType} from '@nuskin/ns-product-lib';
|
|
8
8
|
import CurrencyService from '../currencyService';
|
|
@@ -214,7 +214,7 @@ export default function Cart(cartData) {
|
|
|
214
214
|
} else {
|
|
215
215
|
currentQty = (currentQty + intQuantity > info.maxQty) ? info.maxQty : currentQty + intQuantity;
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
this.setItemQuantity(currentItem.key, parseInt(currentQty), referrer);
|
|
219
219
|
}
|
|
220
220
|
} else {
|
|
@@ -330,7 +330,9 @@ export default function Cart(cartData) {
|
|
|
330
330
|
* @returns nuskin.newShop.CartItem
|
|
331
331
|
*/
|
|
332
332
|
this.getFirstItemBySku = function(sku, options = {cartItems: true}) {
|
|
333
|
-
let item = this.getItems(options).find(
|
|
333
|
+
let item = this.getItems(options).find(
|
|
334
|
+
(item) => item.product.sku === sku || (item.product.agelocme && item.product.agelocme.code === sku)
|
|
335
|
+
);
|
|
334
336
|
|
|
335
337
|
return item ? item.toFlatJson() : null;
|
|
336
338
|
};
|
|
@@ -553,8 +553,8 @@ const syncProductItems = (order, sapProducts, adr, includeSapItems) => {
|
|
|
553
553
|
order.addOutOfStock(sapItem.LineItem.SKU);
|
|
554
554
|
order.addOutOfStockTitle(CartService.getItemTitleBySku(sapItem.LineItem.SKU));
|
|
555
555
|
} else {
|
|
556
|
-
let
|
|
557
|
-
|
|
556
|
+
let existingItem = CartService.getFirstItemBySku(sapItem.LineItem.SKU, includeSapItems ? {all: true} : {cartItems: true}),
|
|
557
|
+
aSku = existingItem ? existingItem.sku : sapItem.LineItem.SKU,
|
|
558
558
|
newItem = {},
|
|
559
559
|
isAdrItem = !sapItem.LineItem.OneTime,
|
|
560
560
|
newItemSku = aSku;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {ConfigService, RunConfigService, UrlService} from '@nuskin/ns-util';
|
|
2
2
|
import {UserService} from '@nuskin/ns-account';
|
|
3
3
|
import {ServiceUtils} from '@nuskin/ns-shop';
|
|
4
|
+
import axios from 'axios';
|
|
4
5
|
|
|
5
6
|
let baseUrl;
|
|
6
7
|
let awsUrl;
|
|
@@ -42,6 +43,7 @@ export default {
|
|
|
42
43
|
putShippingAddress,
|
|
43
44
|
deleteShippingAddress,
|
|
44
45
|
getShipDays,
|
|
46
|
+
getVNRegionList,
|
|
45
47
|
getListOfCitiesFromPostalCode
|
|
46
48
|
};
|
|
47
49
|
|
|
@@ -129,6 +131,23 @@ async function getShipDays () {
|
|
|
129
131
|
return shipDays;
|
|
130
132
|
}
|
|
131
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves region, district, and city data for Vietnam.
|
|
136
|
+
* @return {Promise<VNRegion[]>}
|
|
137
|
+
*/
|
|
138
|
+
async function getVNRegionList () {
|
|
139
|
+
if (!baseUrl) {
|
|
140
|
+
baseUrl = ConfigService.getMarketConfig().siteUrl;
|
|
141
|
+
}
|
|
142
|
+
const url = baseUrl + '/static/address-form-assets/vn-regions.json';
|
|
143
|
+
|
|
144
|
+
const { data } = await axios.get(url, {
|
|
145
|
+
headers: { Accept: 'application/json' }
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return data || [];
|
|
149
|
+
}
|
|
150
|
+
|
|
132
151
|
/**
|
|
133
152
|
* Retrieves address data matching the given postal code and country. Postal code may
|
|
134
153
|
* resolve down to a region, district, or city.
|
|
@@ -249,3 +268,16 @@ function getHeaders(eid) {
|
|
|
249
268
|
* @property {string} [shippingInstructions]
|
|
250
269
|
* @property {string} [shippingAlias]
|
|
251
270
|
*/
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @typedef VNRegion
|
|
274
|
+
* @property {string} value
|
|
275
|
+
* @property {string} text
|
|
276
|
+
* @property {VNDistrict[]} districts
|
|
277
|
+
*/
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @typedef VNDistrict
|
|
281
|
+
* @property {string} text
|
|
282
|
+
* @property {string[]} cities
|
|
283
|
+
*/
|