@nuskin/ns-product-lib 2.7.1-cx24-3684.2 → 2.7.2-cdb-1.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,16 +1,45 @@
1
- ## [2.7.1-cx24-3684.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.1-cx24-3684.1...v2.7.1-cx24-3684.2) (2023-04-16)
1
+ ## [2.7.2-cdb-1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.1...v2.7.2-cdb-1.1) (2023-04-17)
2
2
 
3
3
 
4
4
  ### Fix
5
5
 
6
- * added event pricing (#CX24-3684) ([fca7e9b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fca7e9b9f01d99682ddff162db40b4a727d018c1)), closes [#CX24-3684](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3684)
6
+ * added some logs (#CDB-1) ([253482b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/253482ba8825d56d9a7e3d8541a83bbbda03e09b)), closes [#CDB-1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CDB-1)
7
7
 
8
- ## [2.7.1-cx24-3684.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0...v2.7.1-cx24-3684.1) (2023-04-13)
8
+ ## [2.7.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0...v2.7.1) (2023-04-15)
9
9
 
10
10
 
11
11
  ### Fix
12
12
 
13
- * set original price as wholesale price (#CX24-3684) ([e1d5650](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e1d5650da1bee59b19977c9af5da58b6ff08485d)), closes [#CX24-3684](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3684)
13
+ * updating text in unit testing ([65393d6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65393d6492b0696a24daa56f79b768cc38e1c7ae))
14
+
15
+ # [2.8.0-cx24-3705.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.8.0-cx24-3705.1...v2.8.0-cx24-3705.2) (2023-04-14)
16
+
17
+
18
+ ### Update
19
+
20
+ * setting correct title if multiple variants ([583e74d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/583e74d41acc7213cd86a48df9076a453da8bb93))
21
+
22
+ # [2.8.0-cx24-3705.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0...v2.8.0-cx24-3705.1) (2023-04-14)
23
+
24
+
25
+ ### Update
26
+
27
+ * setting correct title if multiple variants ([9574804](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9574804094f65261ff45c9658ba4e4d4baf0bdf2))
28
+
29
+ ## [2.7.1-cx24-3879.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.1-cx24-3879.1...v2.7.1-cx24-3879.2) (2023-04-13)
30
+
31
+
32
+ ### Fix
33
+
34
+ * Payload for subscription products are missing when added to cart from MySite homepage ([20b0ed2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/20b0ed2661b4d213147cef9e77d268b167b49421))
35
+
36
+ ## [2.7.1-cx24-3879.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0...v2.7.1-cx24-3879.1) (2023-04-13)
37
+
38
+
39
+ ### Fix
40
+
41
+ * Payload for subscription products are missing when added to cart from MySite homepage ([7b7ac3b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7b7ac3bd7c0b196aa9a7e97e885f7e296ef7e97d))
42
+ * Payload for subscription products are missing when added to cart from MySite homepage ([d49957f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d49957f44d9ce6b6469b0bc94bc8f8050d00f35a))
14
43
 
15
44
  # [2.7.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.2...v2.7.0) (2023-04-05)
16
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.7.1-cx24-3684.2",
3
+ "version": "2.7.2-cdb-1.1",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@nuskin/configuration-sdk": "2.2.3",
35
35
  "@nuskin/ns-common-lib": "1.4.5",
36
- "@nuskin/ns-util": "4.2.7",
36
+ "@nuskin/ns-util": "4.3.2",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
39
39
  },
package/src/product.js CHANGED
@@ -75,7 +75,7 @@ const Product = function (productData) {
75
75
  //equinox inventory / stock label
76
76
  //@example "IN STOCK"
77
77
  this.inventory = "";
78
-
78
+
79
79
  // equinox specific properties
80
80
  this.equinoxProductId = "";
81
81
  this.properties = {};
@@ -262,7 +262,6 @@ const Product = function (productData) {
262
262
 
263
263
  if (option.isEqPromotion) {
264
264
  //retain product.price as original price
265
- this.setPrice(this.getPricing(priceType));
266
265
  this.setCv(this.getCvWithType(priceType));
267
266
  this.setPv(this.getPvWithType(priceType));
268
267
  this.priceType = priceType;
@@ -338,7 +337,11 @@ const Product = function (productData) {
338
337
  return this.addCvWithType(csvKey, productStatus.csv[csvKey]);
339
338
  }, this);
340
339
  }
341
- this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
340
+ //only remap the orderTypes for legacy (which we'll know when equinoxProductId is blank)
341
+ if(this.equinoxProductId == "") {
342
+ this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
343
+ }
344
+
342
345
  if (productStatus.childSkus) {
343
346
  this.childSkus = productStatus.childSkus;
344
347
  }
@@ -21,20 +21,48 @@ const ProductData = {
21
21
  * @param {boolean} isEquinoxEnabled
22
22
  */
23
23
  getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
24
+ console.trace({
25
+ where: 'productData getProductData',
26
+ skus,
27
+ locale,
28
+ market,
29
+ isEquinoxEnabled
30
+ })
24
31
  const localeMarket = `${locale}_${market}`;
25
32
 
26
33
  if (isEquinoxEnabled) {
27
34
  const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
35
+ console.trace({
36
+ where: 'productData getProductData',
37
+ config
38
+ })
28
39
 
29
40
  if (config.country_code === market && config.active) {
41
+ console.trace({
42
+ where: 'productData getProductData equinox path',
43
+ config
44
+ })
30
45
  return await this.getProductFromEquinox(skus, localeMarket, config);
31
46
  }
32
47
  }
48
+ console.trace({
49
+ where: 'productData getProductData legacy path'
50
+ })
33
51
  return await this.getProductFromLegacy(skus, localeMarket);
34
52
  },
35
53
 
36
54
  getProductFromEquinox: async function (skus, locale, config) {
55
+ console.trace({
56
+ where: 'productData getProductFromEquinox',
57
+ skus,
58
+ locale,
59
+ config
60
+ })
37
61
  const response = await this.searchEquinoxProduct(skus, locale, config);
62
+ console.trace({
63
+ where: 'productData getProductFromEquinox',
64
+ response
65
+ })
38
66
 
39
67
  if (response.data.product) {
40
68
  return await this.eqProductMapper(response.data.product, skus);
@@ -48,11 +76,11 @@ const ProductData = {
48
76
  },
49
77
 
50
78
  /**
51
- *
52
- * @param {string[]} skus
53
- * @param {string} locale
54
- * @param {ConfigMap} config
55
- * @returns
79
+ *
80
+ * @param {string[]} skus
81
+ * @param {string} locale
82
+ * @param {ConfigMap} config
83
+ * @returns
56
84
  */
57
85
  searchEquinoxProduct: async function (skus, locale, config) {
58
86
  let skuFilter = [];
@@ -94,7 +122,16 @@ const ProductData = {
94
122
  },
95
123
 
96
124
  getProductFromLegacy: async function (skus, locale) {
125
+ console.trace({
126
+ where: 'productData getProductFromLegacy',
127
+ skus,
128
+ locale
129
+ })
97
130
  const marketConfig = await contentstack.getAEMConfig();
131
+ console.trace({
132
+ where: 'productData getProductFromLegacy',
133
+ marketConfig
134
+ })
98
135
 
99
136
  if (marketConfig === null) {
100
137
  return null;
@@ -140,7 +177,6 @@ const ProductData = {
140
177
  const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
141
178
  const productCVPrice = eventName ? CVPrice : eqVariant.priceFacets.CV;
142
179
  const productPVPrice = eventName ? PVPrice : eqVariant.priceFacets.PV;
143
- const wholeSalePrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Wholesale Price"];
144
180
 
145
181
  return {
146
182
  "sku": eqVariant.identifier,
@@ -253,12 +289,12 @@ const ProductData = {
253
289
  "price": discountedPrice,
254
290
  "priceMap": {
255
291
  "WRTL": productPrice,
256
- "WADW-WRTL": productPrice,
257
- "WADR": productPrice,
258
- "RTL": productPrice,
259
- "WWHL": wholeSalePrice,
260
- "WADW": wholeSalePrice,
261
- "WHL": wholeSalePrice
292
+ "WADW-WRTL": eqVariant.priceFacets["Regular Price"],
293
+ "WADR": eqVariant.priceFacets["Regular Price"],
294
+ "RTL": eqVariant.priceFacets["Regular Price"],
295
+ "WWHL": eqVariant.priceFacets["Wholesale Price"],
296
+ "WADW": eqVariant.priceFacets["Wholesale Price"],
297
+ "WHL": eqVariant.priceFacets["Wholesale Price"]
262
298
  },
263
299
  "cvMap": {
264
300
  "WWHL": productCVPrice,
@@ -365,7 +401,7 @@ const ProductData = {
365
401
  let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
366
402
  let imageURL = product.properties.imageURL ? product.properties.imageURL : '';
367
403
  let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
368
-
404
+ let productTitle = productData.properties.name
369
405
 
370
406
  if (productData.sku && productData.sku.length > 1) {
371
407
  // exclude base product from variants
@@ -373,6 +409,10 @@ const ProductData = {
373
409
  variants[variant.identifier] = this.eqProductVariantMapper(variant);
374
410
  return variant;
375
411
  });
412
+ const productArr = productData.sku.filter(p => p.default === true)
413
+ productTitle = productArr[0].properties.name;
414
+ product = productArr[0]
415
+
376
416
  }
377
417
 
378
418
  const {
@@ -384,11 +424,9 @@ const ProductData = {
384
424
  PVPrice
385
425
  } = this.getEqProductPromotions(product);
386
426
  const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
387
- const discountedPrice = eventName ? computedPrice : product.priceFacets["Wholesale Price"];
427
+ const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
388
428
  const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
389
429
  const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
390
- const wholeSalePrice = eventName ? defaultProductPrice : product.priceFacets["Wholesale Price"];
391
-
392
430
 
393
431
  product.childSkus = await this.fetchChildSkus(product);
394
432
  product.availableQuantity = mapAvailableQuantity(product);
@@ -396,7 +434,7 @@ const ProductData = {
396
434
  ...product,
397
435
  "sku": product.identifier,
398
436
  "globalProductID": productData.identifier,
399
- "title": productData.properties.name,
437
+ "title": productTitle,
400
438
  "country": product.properties.market,
401
439
  "language": "en",
402
440
  "shortDescr": productData.properties.description,
@@ -432,13 +470,13 @@ const ProductData = {
432
470
  "priceType": "WRTL",
433
471
  "price": discountedPrice,
434
472
  "priceMap": {
435
- "WRTL": productPrice, //regular | retail price
436
- "WADW-WRTL": productPrice,
437
- "WADR": productPrice,
438
- "RTL": productPrice,
439
- "WADW": wholeSalePrice,
440
- "WHL": wholeSalePrice,
441
- "WWHL": wholeSalePrice
473
+ "WRTL": productPrice,
474
+ "WADW-WRTL": product.priceFacets["Regular Price"],
475
+ "WADR": product.priceFacets["Regular Price"],
476
+ "RTL": product.priceFacets["Regular Price"],
477
+ "WADW": product.priceFacets["Wholesale Price"],
478
+ "WHL": product.priceFacets["Wholesale Price"],
479
+ "WWHL": product.priceFacets["Wholesale Price"]
442
480
  },
443
481
  "cvMap": {
444
482
  "WWHL": productCVPrice,
@@ -513,7 +551,7 @@ const ProductData = {
513
551
  };
514
552
  },
515
553
 
516
- mapEquinoxSKUExists: function(exists) {
554
+ mapEquinoxSKUExists: function (exists) {
517
555
  // this could be avoided if only we are using response mapper
518
556
  // for equinox products that exists.
519
557
  // @todo: clean-up