@nuskin/ns-shop 7.0.11-pur-813.2 → 7.0.11-pur-813.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "7.0.11-pur-813.2",
3
+ "version": "7.0.11-pur-813.3",
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,7 +26,7 @@
26
26
  "@nuskin/ns-common-lib": "1.4.7",
27
27
  "@nuskin/ns-feature-flags": "1.4.7",
28
28
  "@nuskin/ns-loyalty-web": "1.5.6",
29
- "@nuskin/ns-product-lib": "2.19.1-pur-816.1",
29
+ "@nuskin/ns-product-lib": "2.19.1",
30
30
  "@nuskin/nuskinjquery": "2.3.1",
31
31
  "@nuskin/order-model": "3.1.3",
32
32
  "@nuskin/product-lib": "2.2.1",
@@ -34,6 +34,7 @@ export default {
34
34
  hasItems,
35
35
  hasEventItems,
36
36
  hasPreviewItems,
37
+ hasDanerousGoods,
37
38
  getItemCnt,
38
39
  addProductToCart,
39
40
  addSkuToCart,
@@ -298,6 +299,14 @@ function hasPreviewItems() {
298
299
  return _getCart().hasPreviewItems();
299
300
  }
300
301
 
302
+ function hasDanerousGoods(options = {cartOrderItems: true}) {
303
+ let retVal = false;
304
+ _getCart().getItems(options).forEach((item) => {
305
+ retVal = retVal || item.product.dangerousGoods;
306
+ });
307
+ return retVal;
308
+ }
309
+
301
310
  function getItemCnt(options) {
302
311
  return _getCart().getItemCnt(options);
303
312
  }
@@ -9,6 +9,7 @@ const extractProductData = (data, sku) => {
9
9
 
10
10
  if (Array.isArray(data.variants) && data.variants.length > 0) {
11
11
  retVal = data.variants.find((variant) => variant.sku === sku);
12
+ retVal.variantSelectLabel = data.variantSelectLabel;
12
13
  } else if (data.bundle) {
13
14
  retVal = data.bundle;
14
15
  retVal.title = data.title;
@@ -118,26 +119,56 @@ const createDataFromSkuSearch = (searchData, options) => {
118
119
  if (!searchData) {
119
120
  return new Product();
120
121
  }
121
- let product = new Product(),
122
- langObj = null, //getLangObj(searchData['contents']['language'], options.language),
123
- marketObj = null; //searchData['market'];
124
- // if (Array.isArray(marketObj)) {
125
- // marketObj = getMarketObj(searchData['market'], options.country);
126
- // }
127
- let {orderType: mktOrderTypes, custType: mktCustTypes, restrictedMarket: restrictedMarkets, addOns} = {}; //marketObj;
122
+ let product = new Product();
128
123
 
129
124
  if (searchData) {
130
125
  product.sku = options.sku;
126
+ product.country = options.country;
131
127
  product.lang = options.language;
132
128
  product.isExclusive = searchData.isExclusive;
133
129
  if (Array.isArray(searchData.productImages) && searchData.productImages.length > 0) {
134
130
  product.setFullImage(searchData.productImages[0].url);
135
131
  product.setThumbnail(searchData.productImages[0].thumbnail);
132
+ product.setImageAltText(searchData.productImages[0].altText);
136
133
  // product.setProductCarouselImages(???searchData.contents.imageCarousel);
137
134
  }
138
135
  // product.productLabels = ???
139
136
  product.title = searchData.title;
140
137
  product.shortDescr = searchData.description;
138
+ // product.longDescr = langObj['longDescription']; looks like it is deprecated
139
+ product.dangerousGoods = searchData.dangerousGoods === true;
140
+ product.ingredients = searchData.ingredients;
141
+ product.benefits = searchData.benefits;
142
+ product.usage = searchData.usage;
143
+ product.resources = searchData.resources;
144
+ // product.videos = searchData.???;
145
+ // product.contentSection =searchData.???;
146
+ // product.sizeWeight = ???;
147
+ product.size = searchData.size;
148
+ product.nettoWeight = searchData.nettoWeight;
149
+ product.salesLabel = searchData.salesLabel;
150
+ // product.movie = searchData.???;
151
+ // product.youtube = searchData.???;
152
+ product.salesEventText = searchData.salesText;
153
+ product.scanQualified = searchData.scanQualifiedCount;
154
+ // product.division = searchData.???
155
+ product.custTypes = Array.isArray(searchData.customerTypes) && searchData.customerTypes.map((ct) => {
156
+ if (ct === 'Preferred') return '30';
157
+ else if (ct === 'Retail') return '20';
158
+ else if (ct === '') return '10';
159
+ });
160
+ product.restrictedMarkets = searchData.restrictedMarkets;
161
+ // if (addOns) {
162
+ // product.addOns = addOns;
163
+ // } else {
164
+ // product.addOns = [];
165
+ // }
166
+ if (options.isGroupOffer) product.isGroupOffer = options.isGroupOffer;
167
+ if (options.isPersonalOffer) product.isPersonalOffer = options.isPersonalOffer;
168
+
169
+ product.variantsLabel = searchData.variantLabel;
170
+ product.variantDropdownLabel = searchData.variantSelectLabel;
171
+ product.shade = searchData.variantColor;
141
172
 
142
173
  const pricing = JSON.parse(searchData.pricingJson);
143
174
  const orderTypes = [];
@@ -158,92 +189,10 @@ const createDataFromSkuSearch = (searchData, options) => {
158
189
  product.addPricingFromStatus(status);
159
190
  }
160
191
 
161
-
162
- if (marketObj !== null) {
163
- // product.sku = searchData.sku;
164
- // product.isExclusive = Object.hasOwn(searchData, 'isExclusive') ? searchData.isExclusive : false;
165
- if (Object.hasOwn(searchData, 'contents')) {
166
- // product.setFullImage(searchData.contents.fullImage);
167
- // product.setThumbnail(searchData.contents.fullImage.replace(/\.img\.[0-9]+\.[0-9]+\.png/i, '.img.160.160.png'));
168
- // if (Object.hasOwn(searchData.contents, 'imageCarousel')) {
169
- // product.setProductCarouselImages(searchData.contents.imageCarousel);
170
- // }
171
- }
172
- // AEM-8320 - it returns two BP (08007070 and 08129080), 08129080 does not have any translation yet.
173
- // Note that langObj can be null (have a BP that does not have any translation)
174
-
175
- // product.productLabels = marketObj['populateProductLabels'];
176
- if (langObj) {
177
- // product.lang = langObj['languageCode'];
178
- // product.title = langObj['name'];
179
- // product.shortDescr = langObj['shortDescription'];
180
- product.longDescr = langObj['longDescription'];
181
- product.ingredients = langObj['ingredients'];
182
- product.benefits = langObj['benefits'];
183
- product.usage = langObj['usage'];
184
- product.resources = langObj['resources'];
185
- product.videos = langObj['videos'];
186
- product.contentSection = langObj['contentSection'];
187
- product.sizeWeight = langObj['size_weight'];
188
- product.nettoWeight = langObj['netto_weight'];
189
- product.salesLabel = langObj['salesLabel'];
190
- product.movie = langObj['movie'];
191
- product.youtube = langObj['youtube'];
192
- product.salesEventText = langObj['tdc_salesEventText'];
193
- if (langObj.variantInfo) {
194
- if (langObj.variantInfo.tdc_dropdownLabel) {
195
- product.variantDropdownLabel = langObj.variantInfo.tdc_dropdownLabel
196
- }
197
- if (langObj.variantInfo.tdc_dropdownPlaceholder) {
198
- product.variantDropdownPlaceholder = langObj.variantInfo.tdc_dropdownPlaceholder;
199
- }
200
- if (langObj.variantInfo.tdc_variantsLabel) {
201
- product.variantsLabel = langObj.variantInfo.tdc_variantsLabel;
202
- }
203
- }
204
- }
205
- product.setImageAltText(searchData['contents']['altText']);
206
- product.country = marketObj['countryCode'];
207
- product.scanQualified = marketObj['scanQualified'];
208
- product.division = searchData['division'];
209
-
210
- if (mktOrderTypes) {
211
- product.orderTypes = mktOrderTypes;
212
- }
213
- if (mktCustTypes) {
214
- product.custTypes = mktCustTypes;
215
- }
216
- if (restrictedMarkets) {
217
- product.restrictedMarkets = restrictedMarkets;
218
- }
219
- if (addOns) {
220
- product.addOns = addOns;
221
- } else {
222
- product.addOns = [];
223
- }
224
-
225
- if (options.isGroupOffer)
226
- product.isGroupOffer = options.isGroupOffer;
227
- if (options.isPersonalOffer)
228
- product.isPersonalOffer = options.isPersonalOffer;
229
- }
230
-
231
- if (searchData.variantConfig) {
232
- if (searchData.variantConfig.variantType) {
233
- product.variantType = searchData.variantConfig.variantType;
234
- }
235
- if (searchData.variantConfig.variants) {
236
- searchData.variantConfig.variants.forEach((variant) => {
237
- product.setVariant(createDataFromSkuSearch(variant, options));
238
- });
239
- }
240
- if (searchData.variantConfig.swatchColor) {
241
- product.shade = searchData.variantConfig.swatchColor;
242
- }
243
- if (searchData.variantConfig.baseSku) {
244
- product.baseSku = searchData.variantConfig.baseSku;
245
- }
246
- }
192
+ // Note: this mapping was originally created for the product data in AEM. This product
193
+ // data comes from content stack and is not identical to what is in AEM. There may
194
+ // need to be some tweaks in here. ESPECIALLY when the data gets moved to the
195
+ // bundle field (vs variants) in the product data.
247
196
 
248
197
  return product;
249
198
  }
@@ -1,10 +1,8 @@
1
- import OrderAdapter from '../order/orderAdapter';
2
1
  import {getCachedConfiguration} from '@nuskin/configuration-sdk';
3
2
  import {Order} from '@nuskin/order-model';
4
3
  import {RunConfigService} from '@nuskin/ns-util';
5
- // import {CartService} from '@nuskin/ns-shop';
4
+ import {OrderManager, CartService, OrderType, OrderAdapter} from '../shop';
6
5
  import axios from 'axios';
7
- import { OrderManager } from '../shop';
8
6
 
9
7
  let PickupUtil = function() {
10
8
  'use strict';
@@ -142,6 +140,20 @@ let PickupUtil = function() {
142
140
  return markers;
143
141
  }
144
142
 
143
+ function getOrderValue() {
144
+ let value = 0;
145
+ const orderType = OrderManager.getOrder().orderType;
146
+ const cartInfo = CartService.getCartInfo();
147
+
148
+ if (orderType === OrderType.SINGLE_ORDER) {
149
+ value = cartInfo.totalOrderPrice;
150
+ } else {
151
+ value = cartInfo.totalOrderPrice + cartInfo.totalAdrPrice;
152
+ }
153
+
154
+ return value;
155
+ }
156
+
145
157
  function getUrl() {
146
158
  switch (RunConfigService.getEnvironmentCode()) {
147
159
  case 'dev':
@@ -164,7 +176,6 @@ let PickupUtil = function() {
164
176
  const {metapackMarket, metapackZipExclusions} = getCachedConfiguration('Checkout');
165
177
 
166
178
  if (metapackMarket) {
167
- const order = OrderManager.getOrder();
168
179
  let includePickupPoints = true;
169
180
  for (const zipRegEx of metapackZipExclusions || []) {
170
181
  const regEx = new RegExp(zipRegEx);
@@ -176,7 +187,8 @@ let PickupUtil = function() {
176
187
  {
177
188
  order,
178
189
  pudo: includePickupPoints,
179
- orderValue: order && order.orderTotals && order.orderTotals.grandTotal || 0.0
190
+ orderValue: getOrderValue(),
191
+ dangerousGoods: CartService.hasDangerousGoods()
180
192
  },
181
193
  {
182
194
  headers: {