@nuskin/ns-product-lib 2.4.2-cx24-2612.1.1 → 2.5.0-CX24.3.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,146 @@
1
+ # [2.5.0-CX24.3.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-CX24.3.1...v2.5.0-CX24.3.2) (2022-12-20)
2
+
3
+
4
+ ### Fix
5
+
6
+ * Slow response of add-to-cart button function for Equinox Cart ([14394b2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/14394b299afbd53254a3ec053ad41e68ed526dfe))
7
+ * Unit Tests ([ace52c6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ace52c6418991d0263a1e1f8d99901e724abf923))
8
+
9
+ ### Update
10
+
11
+ * use configuration-sdk to pull the configurations (CX24-2931) ([6934570](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/69345701e6b44754ffeb648ead56f0288aadeb16))
12
+
13
+ # [2.5.0-cx24-2931.1.12](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.11...v2.5.0-cx24-2931.1.12) (2022-12-15)
14
+
15
+
16
+ ### Update
17
+
18
+ * use configuration-sdk to pull the configurations (CX24-2931) ([407402f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/407402fbcfb3a782dec95b5ff1038c1fb3fe31ca))
19
+
20
+ # [2.5.0-cx24-2931.1.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.10...v2.5.0-cx24-2931.1.11) (2022-12-14)
21
+
22
+
23
+ ### Update
24
+
25
+ * use configuration-sdk to pull the configurations (CX24-2931) ([fc2010c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fc2010cdf7dfb7ecd53940d64e94f43c045135c5))
26
+
27
+ # [2.5.0-cx24-2931.1.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.9...v2.5.0-cx24-2931.1.10) (2022-12-14)
28
+
29
+
30
+ ### Update
31
+
32
+ * use configuration-sdk to pull the configurations (CX24-2931) ([73cd345](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/73cd3459f0d3a4486a6b7798bdb1dab0231e7c5a))
33
+
34
+ # [2.5.0-cx24-2931.1.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.8...v2.5.0-cx24-2931.1.9) (2022-12-14)
35
+
36
+
37
+ ### Update
38
+
39
+ * use configuration-sdk to pull the configurations (CX24-2931) ([24096f4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/24096f46bc77881ca7273b10d9fbef85757d2d92))
40
+
41
+ # [2.5.0-cx24-2931.1.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.7...v2.5.0-cx24-2931.1.8) (2022-12-14)
42
+
43
+
44
+ ### Update
45
+
46
+ * use configuration-sdk to pull the configurations (CX24-2931) ([2f1a466](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2f1a466c39ea57e095e8de53cd4651aa2cf6cc8d))
47
+
48
+ # [2.5.0-cx24-2931.1.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.6...v2.5.0-cx24-2931.1.7) (2022-12-14)
49
+
50
+
51
+ ### Update
52
+
53
+ * use configuration-sdk to pull the configurations (CX24-2931) ([f54271c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f54271c59f12f0eefb20a7ced67efe7058f079a3))
54
+
55
+ # [2.5.0-cx24-2931.1.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.5...v2.5.0-cx24-2931.1.6) (2022-12-14)
56
+
57
+
58
+ ### Update
59
+
60
+ * use configuration-sdk to pull the configurations (CX24-2931) ([527d80f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/527d80fee9396e87cf1e92c223790c33bcba681f))
61
+
62
+ # [2.5.0-cx24-2931.1.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.4...v2.5.0-cx24-2931.1.5) (2022-12-14)
63
+
64
+
65
+ ### New
66
+
67
+ * use configuration-sdk to pull the configurations (CX24-2931) ([0373219](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/03732199ae3864b9d690b58523011598187356ea))
68
+ * use configuration-sdk to pull the configurations (CX24-2931) ([34b6954](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/34b6954dcd751a390ee2395fe1a3ca42481affc8))
69
+
70
+ ### Update
71
+
72
+ * use configuration-sdk to pull the configurations (CX24-2931) ([6cf3a1d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6cf3a1d38cc0af3affade68d441a30a4b9dc7789))
73
+ * use configuration-sdk to pull the configurations (CX24-2931) ([11655c4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/11655c46484aa6e6e359522c707c64f496755976))
74
+
75
+ # [2.5.0-cx24-2931.1.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.3...v2.5.0-cx24-2931.1.4) (2022-12-14)
76
+
77
+
78
+ ### Update
79
+
80
+ * use configuration-sdk to pull the configurations (CX24-2931) ([9abdf43](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9abdf4326fa55692045f5a3cc91f5725afe94cb2))
81
+
82
+ # [2.5.0-cx24-2931.1.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.2...v2.5.0-cx24-2931.1.3) (2022-12-14)
83
+
84
+
85
+ ### Update
86
+
87
+ * use configuration-sdk to pull the configurations (CX24-2931) ([0f4bf7d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0f4bf7dfb6e1c3c6d6b0c00fd08cca3c1920cbec))
88
+
89
+ # [2.5.0-cx24-2931.1.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2931.1.1...v2.5.0-cx24-2931.1.2) (2022-12-14)
90
+
91
+
92
+ ### Update
93
+
94
+ * use configuration-sdk to pull the configurations (CX24-2931) ([73acfe8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/73acfe8c8aac29e11367f329889956b857460d72))
95
+ * use configuration-sdk to pull the configurations (CX24-2931) ([65c81f5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65c81f5486712690f9cda8faf4e2264238009e82))
96
+
97
+ # [2.5.0-cx24-2931.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-CX24.3.1...v2.5.0-cx24-2931.1.1) (2022-12-13)
98
+
99
+
100
+ ### Update
101
+
102
+ * use configuration-sdk to pull the configurations (CX24-2931) ([e8931ac](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e8931aca51591c59b401c4c386f23c8f7d4c5a90))
103
+ * use configuration-sdk to pull the configurations (CX24-2931) ([4a1949a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4a1949a20213478994ff51e4b035f52271b7a840))
104
+ * use configuration-sdk to pull the configurations (CX24-2931) ([9a0c9cb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9a0c9cb75a39cd1b77bd6272ac573d4f9b628975))
105
+ * use configuration-sdk to pull the configurations (CX24-2931) ([622c608](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/622c60867b07f0fccd316423cba1500a8470e9e2))
106
+ * use configuration-sdk to pull the configurations (CX24-2931) ([c276e62](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c276e6223953cf72b791887274a5f11d218696e0))
107
+
108
+ # [2.5.0-CX24.3.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-CX24.3.1) (2022-12-06)
109
+
110
+
111
+ ### Fix
112
+
113
+ * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([a89af4a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a89af4a5d00c6a68fcaeff22f128554270add21e))
114
+ * eq market event pricing and name (#CX24-2179) ([213b59a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/213b59a33a208ffad0a6726521ce7f365d34d36e)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
115
+
116
+ ### Release
117
+
118
+ * Automated changes by GitLab pipeline [skip ci] ([07bfa40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/07bfa404c552c05637c2c8a537c4ff298536874e))
119
+ * Automated changes by GitLab pipeline [skip ci] ([fa1c0d9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa1c0d9d5853482e3ac49cea4e99599e7192f85b))
120
+ * Automated changes by GitLab pipeline [skip ci] ([2d20787](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2d2078763b2d57edb8a24f438ac90dd37c3ff41b))
121
+
122
+ ### Update
123
+
124
+ * set ADR pricing from equinox (CX24-2862) ([65d04d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65d04d2e9ff4018edfe99e5a7412bee985d3def2))
125
+ * set ADR pricing from equinox (CX24-2862) ([54a5693](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/54a56932e5df36c9c30ce6358d8597c98be3d20d))
126
+ * set ADR pricing from equinox (CX24-2862) ([bbd135f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bbd135f1ed0395c578be2274c84ba136ceed9376))
127
+ * set ADR pricing from equinox (CX24-2862) ([197003e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/197003e1629bd394c547a118d332b5e8574dfc7d))
128
+
129
+ # [2.5.0-cx24-2862.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2862.1...v2.5.0-cx24-2862.2) (2022-11-11)
130
+
131
+
132
+ ### Update
133
+
134
+ * set ADR pricing from equinox (CX24-2862) ([b64dcea](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b64dcea4dd3374be992c667db5c0b2604aacc029))
135
+
136
+ # [2.5.0-cx24-2862.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-cx24-2612.1.1...v2.5.0-cx24-2862.1) (2022-11-10)
137
+
138
+
139
+ ### Update
140
+
141
+ * set ADR pricing from equinox (CX24-2862) ([9f6dfb7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f6dfb726f40b1335411318629a2ebdf1b4dac96))
142
+ * set ADR pricing from equinox (CX24-2862) ([61f550a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/61f550a21c5cc9d062549ec2aaf2758aebccf2be))
143
+
1
144
  ## [2.4.2-cx24-2612.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-cx24-2612.1.1) (2022-11-07)
2
145
 
3
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.4.2-cx24-2612.1.1",
3
+ "version": "2.5.0-CX24.3.2",
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": {
@@ -31,6 +31,7 @@
31
31
  "prettier": "1.19.1"
32
32
  },
33
33
  "dependencies": {
34
+ "@nuskin/configuration-sdk": "1.0.1",
34
35
  "@nuskin/ns-common-lib": "1.4.5",
35
36
  "@nuskin/ns-util": "3.107.0",
36
37
  "axios": "0.27.2",
@@ -21,7 +21,6 @@ function usePlatformSpecificVariables() {
21
21
  }
22
22
 
23
23
  function useWebEnvironment() {
24
- console.log('web');
25
24
  const env = getEnvironmentFromUrl(window.location.host);
26
25
  const envConfig = config.getCredentials(env);
27
26
  const baseURL = `${envConfig.url}/stacks/${envConfig.apiKey}?environment=${envConfig.env}`;
package/src/product.js CHANGED
@@ -75,6 +75,7 @@ const Product = function(productData) {
75
75
  //equinox inventory / stock label
76
76
  //@example "IN STOCK"
77
77
  this.inventory = "";
78
+ this.equinoxProductId = "";
78
79
 
79
80
  this.setMarketAttributes = function(productStatus) {
80
81
  if (productStatus.marketAttributes) {
@@ -225,7 +226,7 @@ const Product = function(productData) {
225
226
  }
226
227
  };
227
228
 
228
- this.setPriceAndPvFromType = function(_priceType, _activeEvents = null) {
229
+ this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
229
230
  // WARNING: priceType needs to be handled client-side
230
231
  // const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
231
232
  // ? PriceType.WWHL
@@ -234,11 +235,11 @@ const Product = function(productData) {
234
235
  const eventPricing = getEventPricing(this, priceType, _activeEvents);
235
236
 
236
237
  let changed = false;
237
- if (
238
+ if ((
238
239
  !this.price ||
239
240
  priceType !== this.priceType ||
240
241
  this.eventName !== eventPricing.eventName
241
- ) {
242
+ ) && !option.isEqPromotion) {
242
243
  this.setPrice(eventPricing.price || this.getPricing(priceType));
243
244
  this.setCv(eventPricing.cv || this.getCvWithType(priceType));
244
245
  this.setPv(eventPricing.pv || this.getPvWithType(priceType));
@@ -247,11 +248,20 @@ const Product = function(productData) {
247
248
  changed = true;
248
249
  }
249
250
 
251
+ if (option.isEqPromotion) {
252
+ //retain product.price as original price
253
+ this.setCv(this.getCvWithType(priceType));
254
+ this.setPv(this.getPvWithType(priceType));
255
+ this.priceType = priceType;
256
+ changed = true;
257
+ }
258
+
250
259
  this.variantSkus().forEach((variantSku) => {
251
260
  if (
252
261
  this.variants[variantSku].setPriceAndPvFromType(
253
262
  priceType,
254
- _activeEvents
263
+ _activeEvents,
264
+ option
255
265
  )
256
266
  ) {
257
267
  changed = true;
@@ -281,7 +291,7 @@ const Product = function(productData) {
281
291
  this.priceMap[type] = price;
282
292
  };
283
293
 
284
- this.addPricingFromStatus = function(productStatus, priceType) {
294
+ this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
285
295
  let modified = false;
286
296
 
287
297
  if (!priceType) {
@@ -319,13 +329,13 @@ const Product = function(productData) {
319
329
  if(productStatus.childSkus) {
320
330
  this.childSkus = productStatus.childSkus;
321
331
  }
322
- this.setPriceAndPvFromType(priceType);
332
+ this.setPriceAndPvFromType(priceType, null, option);
323
333
  modified = true;
324
334
  } else {
325
335
  let variant = this.getVariant(productStatusSku);
326
336
 
327
337
  if (variant) {
328
- if (variant.addPricingFromStatus(productStatus, priceType)) {
338
+ if (variant.addPricingFromStatus(productStatus, priceType, option)) {
329
339
  variant.setMarketAttributes(productStatus);
330
340
  updateBaseRanges(this, variant);
331
341
  modified = true;
@@ -523,6 +533,7 @@ const Product = function(productData) {
523
533
  retData.restrictedMarkets = this.restrictedMarkets;
524
534
  retData.addOns = this.addOns;
525
535
  retData.inventory = this.inventory;
536
+ retData.equinoxProductId = this.equinoxProductId;
526
537
 
527
538
  return retData;
528
539
  };
@@ -662,6 +673,8 @@ const Product = function(productData) {
662
673
  if (data.agelocme) {
663
674
  this.agelocme = new Agelocme(data.agelocme);
664
675
  }
676
+
677
+ this.equinoxProductId = data.equinoxProductId;
665
678
  }
666
679
  };
667
680
 
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ const { getConfiguration } = require('@nuskin/configuration-sdk');
3
+ // import { ConfigService } from '@nuskin/ns-util';
2
4
  const axios = require("axios");
3
5
  const contentstack = require('./contentstack/contentstack');
4
6
  const Product = require("./product");
@@ -15,28 +17,30 @@ const ProductData = {
15
17
  const localeMarket = `${locale}_${market}`;
16
18
 
17
19
  if (isEquinoxEnabled) {
18
- const marketConfig = await contentstack.isMarketEnabled(market);
19
-
20
- if (marketConfig !== null) {
21
- return await this.getProductFromEquinox(skus, localeMarket, marketConfig.store_id);
22
- }
20
+ return await this.getProductFromEquinox(skus, localeMarket);
23
21
  }
24
22
 
25
23
  return await this.getProductFromLegacy(skus, localeMarket);
26
24
  },
27
-
28
- getProductFromEquinox: async function (skus, locale, storeID) {
29
- const filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' + skus.toString() + '"}]}';
25
+
26
+ getProductFromEquinox: async function (skus, locale) {
27
+ const config = (await getConfiguration({
28
+ configMapNames: ['Equinox_Markets'],
29
+ country: locale.split('_')[1],
30
+ environment: 'test',
31
+ clientId: '735b1eb810304bba966af0891ab54053'
32
+ })).Equinox_Markets;
33
+ const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
30
34
  axios.defaults.withCredentials = true;
31
35
 
32
- const url = await contentstack.getKongUrl() + `/orchestrationservices/storefront/catalogs/search/`;
36
+ const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
33
37
  const href = `${url}?filter=${encodeURI(filter)}`;
34
38
  const response = await axios.request({
35
39
  method: 'get',
36
40
  url: href,
37
41
  params: {
38
42
  locale,
39
- storeId: storeID
43
+ storeId: config.store_id
40
44
  },
41
45
  headers: this.getEquinoxRequestHeaders(),
42
46
  responseType: 'json'
@@ -91,7 +95,7 @@ const ProductData = {
91
95
 
92
96
  /**
93
97
  * Map product variant
94
- * @todo remove unnecessary fields
98
+ * @todo remove unnecessary fields and do code refactoring
95
99
  * @param {*} eqVariant
96
100
  * @returns Array<Product>
97
101
  */
@@ -107,6 +111,10 @@ const ProductData = {
107
111
  thumbnailImage = imageURL.replace(regex,'40.40')
108
112
  }
109
113
 
114
+ const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(eqVariant);
115
+ const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
116
+ const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
117
+
110
118
  return {
111
119
  "sku": eqVariant.identifier,
112
120
  "globalProductID": eqVariant.identifier,
@@ -145,14 +153,14 @@ const ProductData = {
145
153
  "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
146
154
  "pv":eqVariant.priceFacets.PV,
147
155
  "priceType": "WRTL",
148
- "price": eqVariant.priceFacets["Regular Price"],
156
+ "price": discountedPrice,
149
157
  "priceMap": {
150
- "WRTL": eqVariant.priceFacets["Regular Price"],
158
+ "WRTL": productPrice,
151
159
  "WADW-WRTL": eqVariant.priceFacets["Regular Price"],
152
- "WADR": 9999.01,
160
+ "WADR": eqVariant.priceFacets["Regular Price"],
153
161
  "RTL": eqVariant.priceFacets["Regular Price"],
154
162
  "WWHL": eqVariant.priceFacets["Wholesale Price"],
155
- "WADW": 9998.01,
163
+ "WADW": eqVariant.priceFacets["Wholesale Price"],
156
164
  "WHL": eqVariant.priceFacets["Wholesale Price"]
157
165
  },
158
166
  "cvMap": {
@@ -165,19 +173,7 @@ const ProductData = {
165
173
  "WADW": eqVariant.priceFacets.PV,
166
174
  "WHL": eqVariant.priceFacets.PV
167
175
  },
168
- "orderTypes": {
169
- "adr": true,
170
- "order": true,
171
- "zpfc": false,
172
- "zadp": true,
173
- "ars": true,
174
- "kiosk": true,
175
- "mobile": true,
176
- "preferred customer": true,
177
- "retail": true,
178
- "web": true,
179
- "web display": true
180
- },
176
+ "orderTypes": this._setOrderType(eqVariant.properties),
181
177
  "division": eqVariant.properties.division,
182
178
  "backOrderDate": null,
183
179
  "locallyProduced": false,
@@ -193,9 +189,9 @@ const ProductData = {
193
189
  "variantsLabel": eqVariant.properties.variantLabel || "",
194
190
  "groupOffer": false,
195
191
  "personalOffer": false,
196
- "savedEventName": null,
197
- "salesLabel": "",
198
- "eventName": null,
192
+ "savedEventName": eventName,
193
+ "salesLabel": eventLabels,
194
+ "eventName": eventName,
199
195
  "sizeWeight": '',
200
196
  "nettoWeight": "",
201
197
  "searchScore": 0,
@@ -206,10 +202,46 @@ const ProductData = {
206
202
  "earn": true
207
203
  },
208
204
  "restrictedMarkets": [],
209
- "addOns": []
205
+ "addOns": [],
206
+ "equinoxProductId": eqVariant.identifier
210
207
  };
211
208
  },
212
209
 
210
+ /**
211
+ * Get EQ product promotions
212
+ * @param {*} product
213
+ * @returns {obj} promotion
214
+ */
215
+ getEqProductPromotions(product) {
216
+
217
+ if (!Array.isArray(product.promotion)) {
218
+ return {
219
+ eventLabels: "",
220
+ computedPrice : 0,
221
+ defaultProductPrice: product.priceFacets ? product.priceFacets["Regular Price"] : 0,
222
+ eventName: null
223
+ }
224
+ }
225
+
226
+ const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
227
+ const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount ? product.totalValue.priceAfterDiscount : 0;
228
+ let eventName = "";
229
+ const eventLabels = [];
230
+
231
+ product.promotion.map(promotion => {
232
+ eventName = promotion.offerId;
233
+ eventLabels.push(promotion.message);
234
+ return promotion;
235
+ });
236
+
237
+ return {
238
+ eventLabels: eventLabels.join(','),
239
+ defaultProductPrice,
240
+ computedPrice,
241
+ eventName
242
+ }
243
+ },
244
+
213
245
  eqProductMapper: function (productDataResponse, skus) {
214
246
  let prod = [];
215
247
  let count = 0;
@@ -227,12 +259,17 @@ const ProductData = {
227
259
  }
228
260
 
229
261
  if (data.sku && data.sku.length > 1) {
230
- data.sku.map(variant => {
262
+ //exclude base product from variants
263
+ data.sku.filter(v => v.identifier.substring(2, 4) !== "55").map(variant => {
231
264
  variants[variant.identifier] = this.eqProductVariantMapper(variant);
232
265
  return variant;
233
266
  });
234
267
  }
235
268
 
269
+ const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(data.sku[count]);
270
+ const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
271
+ const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
272
+
236
273
  prod = {
237
274
  "sku": data.sku[count].identifier,
238
275
  "globalProductID": data.identifier,
@@ -271,13 +308,13 @@ const ProductData = {
271
308
  "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
272
309
  "pv": data.sku[count].priceFacets.PV,
273
310
  "priceType": "WRTL",
274
- "price": data.sku[count].priceFacets["Regular Price"],
311
+ "price": discountedPrice,
275
312
  "priceMap": {
276
- "WRTL": data.sku[count].priceFacets["Regular Price"],
313
+ "WRTL": productPrice,
277
314
  "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
278
- "WADR": 9999.01,
315
+ "WADR": data.sku[count].priceFacets["Regular Price"],
279
316
  "RTL": data.sku[count].priceFacets["Regular Price"],
280
- "WADW": 9998.01,
317
+ "WADW": data.sku[count].priceFacets["Wholesale Price"],
281
318
  "WHL": data.sku[count].priceFacets["Wholesale Price"],
282
319
  "WWHL": data.sku[count].priceFacets["Wholesale Price"]
283
320
  },
@@ -291,19 +328,7 @@ const ProductData = {
291
328
  "WADW": data.sku[count].priceFacets.PV,
292
329
  "WHL": data.sku[count].priceFacets.PV
293
330
  },
294
- "orderTypes": {
295
- "adr": true,
296
- "order": true,
297
- "zpfc": false,
298
- "zadp": true,
299
- "ars": true,
300
- "kiosk": true,
301
- "mobile": true,
302
- "preferred customer": true,
303
- "retail": true,
304
- "web": true,
305
- "web display": true
306
- },
331
+ "orderTypes": this._setOrderType(data.sku[count].properties),
307
332
  "childSkus": [],
308
333
  "custTypes": this.switchCustType(data.properties.customerTypes),
309
334
  "division": data.properties.division,
@@ -321,9 +346,9 @@ const ProductData = {
321
346
  "variantsLabel": data.sku[count].properties.variantLabel || "",
322
347
  "groupOffer": false,
323
348
  "personalOffer": false,
324
- "savedEventName": null,
325
- "salesLabel": "",
326
- "eventName": null,
349
+ "savedEventName": eventName,
350
+ "salesLabel": eventLabels,
351
+ "eventName": eventName,
327
352
  "sizeWeight": '',
328
353
  "nettoWeight": "",
329
354
  "variants": variants,
@@ -336,12 +361,12 @@ const ProductData = {
336
361
  },
337
362
  "restrictedMarkets": [],
338
363
  "addOns": [],
339
- "inventory": data.sku[count].inventory || "" //inventory label
340
-
364
+ "inventory": data.sku[count].inventory || "", //inventory label
365
+ "equinoxProductId": data.identifier
341
366
  };
342
367
  let newProduct = new Product(prod);
343
368
  return newProduct
344
- })
369
+ });
345
370
 
346
371
  let data = {
347
372
  products: this._sortProductsBySku(skus, prodArr),
@@ -415,6 +440,63 @@ const ProductData = {
415
440
 
416
441
  return sortedProducts
417
442
 
443
+ },
444
+
445
+ /**
446
+ *
447
+ * @param {*} availableChannels
448
+ *
449
+ * This function is use to convert arsPhone,web,kiosk,mobile,subscription
450
+ * to orderType object
451
+ * "adr”
452
+ "order"
453
+ "zpfc"
454
+ "zadp"
455
+ "ars"
456
+ "kiosk"
457
+ "mobile"
458
+ "preferred customer"
459
+ "retail"
460
+ "web"
461
+ "web display"
462
+ */
463
+ _setOrderType: function (properties) {
464
+ let orderTypeArr = {
465
+ "adr": false,
466
+ "order": false,
467
+ "zpfc": false,
468
+ "zadp": false,
469
+ "ars": false,
470
+ "kiosk": false,
471
+ "mobile": false,
472
+ "preferred customer": false,
473
+ "retail": false,
474
+ "web": false,
475
+ "web display": false
476
+ };
477
+ let availableChannelsArr = properties.availableChannels.split(',')
478
+
479
+ availableChannelsArr.forEach(channel => {
480
+ if (channel == 'arsPhone')
481
+ orderTypeArr.ars = true
482
+ if (channel == 'web') {
483
+ orderTypeArr.order = true
484
+ orderTypeArr.web = true
485
+ }
486
+ if (channel == 'kiosk')
487
+ orderTypeArr.kiosk = true
488
+ if (channel == 'mobile')
489
+ orderTypeArr.mobile = true
490
+ if (channel == 'subscription')
491
+ orderTypeArr.adr = true
492
+
493
+ });
494
+ if (properties.retail)
495
+ orderTypeArr.retail = true
496
+ if (properties.prefferredCustomer)
497
+ orderTypeArr['preferred customer'] = true
498
+
499
+ return orderTypeArr;
418
500
  }
419
501
  }
420
502