@nuskin/ns-product-lib 2.6.0-cx24-33721.2 → 2.6.0-cx24-3377.11

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,16 +1,84 @@
1
- # [2.6.0-cx24-33721.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-33721.1...v2.6.0-cx24-33721.2) (2023-03-09)
1
+ # [2.6.0-cx24-3377.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.10...v2.6.0-cx24-3377.11) (2023-03-10)
2
2
 
3
3
 
4
- ### Update
4
+ ### New
5
+
6
+ * Fix multiple variants not loading properly (CX24-3377) ([9f8273b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f8273b5a8ae3aaf40fb417d04e2087b4b0f036b))
7
+
8
+ # [2.6.0-cx24-3377.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.9...v2.6.0-cx24-3377.10) (2023-03-09)
9
+
10
+
11
+ ### New
12
+
13
+ * Fix multiple variants not loading properly (CX24-3377) ([1b08b2a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1b08b2ad4ea7bdceca494f6121f14f74236afb97))
14
+
15
+ # [2.6.0-cx24-3377.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.8...v2.6.0-cx24-3377.9) (2023-03-09)
16
+
17
+
18
+ ### New
19
+
20
+ * Fix multiple variants not loading properly (CX24-3377) ([fbeaa05](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fbeaa050c39a486c81979e6034ce1ae19a613ff6))
21
+
22
+ # [2.6.0-cx24-3377.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.7...v2.6.0-cx24-3377.8) (2023-03-09)
23
+
24
+
25
+ ### New
26
+
27
+ * Fix multiple variants not loading properly (CX24-3377) ([e32840a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e32840aabdec5b13c7a6b8dd276adb523689890f))
28
+
29
+ # [2.6.0-cx24-3377.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.6...v2.6.0-cx24-3377.7) (2023-03-09)
30
+
31
+
32
+ ### New
33
+
34
+ * Fix multiple variants not loading properly (CX24-3377) ([15431ae](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/15431aef763e3d70ab8d1485509ec571df3b78f3))
35
+
36
+ # [2.6.0-cx24-3377.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.5...v2.6.0-cx24-3377.6) (2023-03-09)
37
+
38
+
39
+ ### New
40
+
41
+ * Fix multiple variants not loading properly (CX24-3377) ([d653c88](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d653c887a529d2e93e05028e9eed8064991470ee))
42
+
43
+ # [2.6.0-cx24-3377.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.4...v2.6.0-cx24-3377.5) (2023-03-09)
44
+
45
+
46
+ ### New
47
+
48
+ * Fix multiple variants not loading properly (CX24-3377) ([d681803](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d681803ccbc2290a0e843e8eb1b191d33ba97cbe))
49
+
50
+ # [2.6.0-cx24-3377.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.3...v2.6.0-cx24-3377.4) (2023-03-09)
51
+
52
+
53
+ ### New
54
+
55
+ * Fix multiple variants not loading properly (CX24-3377) ([1b37ed5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1b37ed513dbd9a8751b8378d5133582b88fdcb97))
56
+ * Fix multiple variants not loading properly (CX24-3377) ([ae2c91f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ae2c91fa98838e60745009e4b66b8c728fad58b8))
57
+
58
+ # [2.6.0-cx24-3377.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.2...v2.6.0-cx24-3377.3) (2023-03-08)
59
+
60
+
61
+ ### New
62
+
63
+ * Fix multiple variants not loading properly (CX24-3377) ([da9eff4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/da9eff46094279a657d6318d96291b94fddcfcf9))
64
+ * Fix multiple variants not loading properly (CX24-3377) ([c6e06c4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c6e06c488ecdd74876c9cb989a8766b473e7d1f2))
65
+ * Fix multiple variants not loading properly (CX24-3377) ([9b75c96](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9b75c96f681bd3c780bf8ba0ac018d525abe7033))
66
+
67
+ # [2.6.0-cx24-3377.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3377.1...v2.6.0-cx24-3377.2) (2023-03-08)
68
+
69
+
70
+ ### New
5
71
 
6
- * removed with credentials default ([48f7bdb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/48f7bdbe9154a82ed48195d0f93f9e4772bf92dc))
72
+ * Fix multiple variants not loading properly (CX24-3377) ([d3a2663](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d3a266319c8ff7b4650c9ef9a06f411b117d98d3))
7
73
 
8
- # [2.6.0-cx24-33721.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.1...v2.6.0-cx24-33721.1) (2023-03-08)
74
+ # [2.6.0-cx24-3377.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.1...v2.6.0-cx24-3377.1) (2023-03-08)
9
75
 
10
76
 
11
77
  ### New
12
78
 
13
- * Update equinox query for KIT and its mapping ([7df6f96](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7df6f9671c58eddb57c9acfd9d4b79b8dec6a78e))
79
+ * Fix multiple variants not loading properly (CX24-3377) ([fb7a856](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fb7a856a39cb7189862d7b7be51b36b15569189e))
80
+ * Fix multiple variants not loading properly (CX24-3377) ([2990272](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/29902726ac21a246638586b5645a070bed1b7fa4))
81
+ * Fix multiple variants not loading properly (CX24-3377) ([0cee74b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0cee74bc366a9032966d235e54b731d03333f902))
14
82
 
15
83
  ## [2.5.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1) (2023-03-07)
16
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.6.0-cx24-33721.2",
3
+ "version": "2.6.0-cx24-3377.11",
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": {
package/src/product.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { isTrue } = require("@nuskin/ns-common-lib");
3
+ const { isTrue } = require("@nuskin/ns-common-lib");
4
4
 
5
5
  const ProductUtils = require("./productUtils.js");
6
6
 
@@ -8,7 +8,7 @@ const Agelocme = require("./agelocme.js");
8
8
  const PriceType = require("./models/priceType.js");
9
9
  const ProductStatus = require("./models/productStatus.js");
10
10
 
11
- const Product = function(productData) {
11
+ const Product = function (productData) {
12
12
  this.priceMap = {};
13
13
  this.pvMap = {};
14
14
  this.cvMap = {};
@@ -77,13 +77,13 @@ const Product = function(productData) {
77
77
  this.inventory = "";
78
78
  this.equinoxProductId = "";
79
79
 
80
- this.setMarketAttributes = function(productStatus) {
80
+ this.setMarketAttributes = function (productStatus) {
81
81
  if (productStatus.marketAttributes) {
82
82
  this.marketAttributes = productStatus.marketAttributes;
83
83
  }
84
84
  };
85
85
 
86
- this.getAgelocmeKeyPart = function() {
86
+ this.getAgelocmeKeyPart = function () {
87
87
  let keyPart = null;
88
88
  if (this.agelocme) {
89
89
  keyPart =
@@ -97,27 +97,27 @@ const Product = function(productData) {
97
97
  return keyPart;
98
98
  };
99
99
 
100
- this.getHighlightedSku = function() {
100
+ this.getHighlightedSku = function () {
101
101
  let rv = this.sku;
102
102
  if (this.highlightedSku) rv = this.highlightedSku;
103
103
  return rv;
104
104
  };
105
105
 
106
- this.getProductSearchTitle = function() {
106
+ this.getProductSearchTitle = function () {
107
107
  if (this.agelocme && this.agelocme.label) {
108
108
  return this.agelocme.label;
109
109
  }
110
110
  return this.title;
111
111
  };
112
112
 
113
- this.getProductSearchSku = function() {
113
+ this.getProductSearchSku = function () {
114
114
  if (this.agelocme && this.agelocme.code) {
115
115
  return this.agelocme.code;
116
116
  }
117
117
  return this.getHighlightedSku();
118
118
  };
119
119
 
120
- this.getDescription = function() {
120
+ this.getDescription = function () {
121
121
  let description = this.longDescr;
122
122
  if (!description || description.length === 0) {
123
123
  return this.shortDescr;
@@ -125,7 +125,7 @@ const Product = function(productData) {
125
125
  return description;
126
126
  };
127
127
 
128
- this.setFullImage = function(fullImage) {
128
+ this.setFullImage = function (fullImage) {
129
129
  if (fullImage) {
130
130
  this.fullImage = fullImage.replace("http:", "https:");
131
131
  } else {
@@ -133,19 +133,19 @@ const Product = function(productData) {
133
133
  }
134
134
  };
135
135
 
136
- this.getFullImage = function() {
136
+ this.getFullImage = function () {
137
137
  return this.fullImage ? this.fullImage.replace("http:", "https:") : "";
138
138
  };
139
139
 
140
- this.setProductCarouselImages = function(productCarouselImages) {
140
+ this.setProductCarouselImages = function (productCarouselImages) {
141
141
  this.productCarouselImages = productCarouselImages;
142
142
  };
143
143
 
144
- this.getProductCarouselImages = function() {
144
+ this.getProductCarouselImages = function () {
145
145
  return this.productCarouselImages;
146
146
  };
147
147
 
148
- this.setImageAltText = function(altText) {
148
+ this.setImageAltText = function (altText) {
149
149
  if (altText) {
150
150
  this.imageAltText = altText;
151
151
  } else {
@@ -153,11 +153,11 @@ const Product = function(productData) {
153
153
  }
154
154
  };
155
155
 
156
- this.getImageAltText = function() {
156
+ this.getImageAltText = function () {
157
157
  return this.imageAltText || this.title;
158
158
  };
159
159
 
160
- this.setThumbnail = function(thumbnail) {
160
+ this.setThumbnail = function (thumbnail) {
161
161
  if (thumbnail) {
162
162
  this.thumbnail = thumbnail.replace("http:", "https:");
163
163
  } else {
@@ -165,7 +165,7 @@ const Product = function(productData) {
165
165
  }
166
166
  };
167
167
 
168
- this.setThumbnailFromSku = function(sku) {
168
+ this.setThumbnailFromSku = function (sku) {
169
169
  // WARNING: Base URL will need to be handled in the client (call setBaseUrl)
170
170
  // eslint-disable-next-line max-len
171
171
  // this.thumbnail = `${RunConfigService.getBaseUrl()}/content/products/${ProductUtils.getTokenizedSku(sku)}/jcr:content/fullImage.img.100.100.png`;
@@ -175,43 +175,43 @@ const Product = function(productData) {
175
175
  )}/jcr:content/fullImage.img.100.100.png`;
176
176
  };
177
177
 
178
- this.getThumbnail = function() {
178
+ this.getThumbnail = function () {
179
179
  return this.thumbnail ? this.thumbnail.replace("http:", "https:") : "";
180
180
  };
181
181
 
182
- this.hasAvailableQuantity = function(qty = 1) {
182
+ this.hasAvailableQuantity = function (qty = 1) {
183
183
  return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
184
184
  };
185
185
 
186
- this.setPoints = function(points) {
186
+ this.setPoints = function (points) {
187
187
  this.points = ensureFloatVal(points) || "";
188
188
  };
189
189
 
190
- this.getPointsFixed = function() {
190
+ this.getPointsFixed = function () {
191
191
  return parseFloat(this.points).toFixed(2);
192
192
  };
193
193
 
194
- this.setCv = function(cv) {
194
+ this.setCv = function (cv) {
195
195
  this.cv = ensureFloatVal(cv) || "";
196
196
  };
197
197
 
198
- this.getCvFixed = function() {
198
+ this.getCvFixed = function () {
199
199
  return parseFloat(this.cv).toFixed(2);
200
200
  };
201
201
 
202
- this.setPv = function(pv) {
202
+ this.setPv = function (pv) {
203
203
  this.pv = ensureFloatVal(pv) || "";
204
204
  };
205
205
 
206
- this.getPvFixed = function() {
206
+ this.getPvFixed = function () {
207
207
  return parseFloat(this.pv || 0).toFixed(2);
208
208
  };
209
209
 
210
- this.setPrice = function(price) {
210
+ this.setPrice = function (price) {
211
211
  this.price = ensureFloatVal(price, true);
212
212
  };
213
213
 
214
- this.setFormattedPrice = function(formattedPrice) {
214
+ this.setFormattedPrice = function (formattedPrice) {
215
215
  this.formattedPrice = formattedPrice;
216
216
  };
217
217
 
@@ -220,13 +220,13 @@ const Product = function(productData) {
220
220
  * added to the cart the event pricing needs to be remembered if toggling between
221
221
  * pricetypes with event pricing and pricetype without event pricing
222
222
  */
223
- this.lockEventName = function() {
223
+ this.lockEventName = function () {
224
224
  if (!this.savedEventName && this.eventName) {
225
225
  this.savedEventName = this.eventName;
226
226
  }
227
227
  };
228
228
 
229
- this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
229
+ this.setPriceAndPvFromType = function (_priceType, _activeEvents = null, option = {}) {
230
230
  // WARNING: priceType needs to be handled client-side
231
231
  // const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
232
232
  // ? PriceType.WWHL
@@ -271,11 +271,11 @@ const Product = function(productData) {
271
271
  return changed;
272
272
  };
273
273
 
274
- this.getPrice = function() {
274
+ this.getPrice = function () {
275
275
  return this.price ? this.price : 0;
276
276
  };
277
277
 
278
- this.getPriceFixed = function() {
278
+ this.getPriceFixed = function () {
279
279
  if (typeof this.price === "number") {
280
280
  return parseFloat(this.price.toFixed(2));
281
281
  } else {
@@ -283,15 +283,15 @@ const Product = function(productData) {
283
283
  }
284
284
  };
285
285
 
286
- this.getOriginalPrice = function() {
286
+ this.getOriginalPrice = function () {
287
287
  return this.priceType ? this.priceMap[this.priceType] : null;
288
288
  };
289
289
 
290
- this.addPricing = function(type, price) {
290
+ this.addPricing = function (type, price) {
291
291
  this.priceMap[type] = price;
292
292
  };
293
293
 
294
- this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
294
+ this.addPricingFromStatus = function (productStatus, priceType, option = {}) {
295
295
  let modified = false;
296
296
 
297
297
  if (!priceType) {
@@ -326,7 +326,7 @@ const Product = function(productData) {
326
326
  }, this);
327
327
  }
328
328
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
329
- if(productStatus.childSkus) {
329
+ if (productStatus.childSkus) {
330
330
  this.childSkus = productStatus.childSkus;
331
331
  }
332
332
  this.setPriceAndPvFromType(priceType, null, option);
@@ -346,15 +346,15 @@ const Product = function(productData) {
346
346
  return modified;
347
347
  };
348
348
 
349
- this.addPvWithType = function(type, pv) {
349
+ this.addPvWithType = function (type, pv) {
350
350
  this.pvMap[type] = pv;
351
351
  };
352
352
 
353
- this.addCvWithType = function(type, cv) {
353
+ this.addCvWithType = function (type, cv) {
354
354
  this.cvMap[type] = cv;
355
355
  };
356
356
 
357
- this.getPricing = function(type) {
357
+ this.getPricing = function (type) {
358
358
  let retVal = null;
359
359
 
360
360
  if (type) {
@@ -381,7 +381,7 @@ const Product = function(productData) {
381
381
  return eventPriceTypes;
382
382
  };
383
383
 
384
- this.getPvWithType = function(type) {
384
+ this.getPvWithType = function (type) {
385
385
  let rv = this.pvMap[type];
386
386
  if (rv == null) {
387
387
  // Assumption: we always have WWHL from the service
@@ -391,7 +391,7 @@ const Product = function(productData) {
391
391
  return rv;
392
392
  };
393
393
 
394
- this.getCvWithType = function(type) {
394
+ this.getCvWithType = function (type) {
395
395
  let rv = this.cvMap[type];
396
396
  if (rv == null) {
397
397
  rv = this.cvMap[PriceType.WWHL];
@@ -399,77 +399,82 @@ const Product = function(productData) {
399
399
  return rv;
400
400
  };
401
401
 
402
- this.hasAdrOption = function() {
402
+ this.hasAdrOption = function () {
403
403
  return this.orderTypes["adr"];
404
404
  };
405
405
 
406
- this.isAdrOnly = function() {
406
+ this.isAdrOnly = function () {
407
407
  return this.hasAdrOption() && !this.hasOrderOption();
408
408
  };
409
409
 
410
- this.hasMultipleOrderTypes = function() {
410
+ this.hasMultipleOrderTypes = function () {
411
411
  return this.hasOrderOption() && this.hasAdrOption();
412
412
  };
413
413
 
414
- this.hasOrderOption = function() {
414
+ this.hasOrderOption = function () {
415
415
  return this.orderTypes["order"];
416
416
  };
417
417
 
418
- this.isDistributor = function() {
418
+ this.isDistributor = function () {
419
419
  return this.custTypes.includes("10");
420
420
  };
421
421
 
422
- this.isCustomer = function() {
422
+ this.isCustomer = function () {
423
423
  return this.custTypes.includes("20");
424
424
  };
425
425
 
426
- this.isPreferredCustomer = function() {
426
+ this.isPreferredCustomer = function () {
427
427
  return this.custTypes.includes("30");
428
428
  };
429
429
 
430
- this.isBase = function() {
430
+ this.isBase = function () {
431
+ if (this.equinoxProductId != "") {
432
+ console.log(this.variants)
433
+ if (this.sku == Object.keys(this.variants)[0])
434
+ return (Object.keys(this.variants).length) ? true : false
435
+ }
431
436
  return this.sku.substring(2, 4) === "55";
432
437
  };
433
438
 
434
- this.isVariant = function() {
439
+ this.isVariant = function () {
435
440
  return this.baseSku.length > 0 && this.variantSkus().length === 0;
436
441
  };
437
442
 
438
- this.setVariant = function(variantProduct) {
443
+ this.setVariant = function (variantProduct) {
439
444
  if (variantProduct && variantProduct.sku) {
440
445
  this.variants[variantProduct.sku] = variantProduct;
441
446
  }
442
447
  };
443
448
 
444
- this.getVariant = function(sku) {
449
+ this.getVariant = function (sku) {
445
450
  return this.variants[sku];
446
451
  };
447
452
 
448
- this.variantSkus = function() {
453
+ this.variantSkus = function () {
449
454
  return Object.keys(this.variants);
450
455
  };
451
456
 
452
- this.getVariantsList = function() {
457
+ this.getVariantsList = function () {
453
458
  return Object.values(this.variants);
454
459
  };
455
460
 
456
- this.getMinPrice = function() {
461
+ this.getMinPrice = function () {
457
462
  return this.priceMap[`min-${this.priceType}`];
458
463
  };
459
464
 
460
- this.getMaxPrice = function() {
465
+ this.getMaxPrice = function () {
461
466
  return this.priceMap[`max-${this.priceType}`];
462
467
  };
463
468
 
464
- this.getMinPv = function() {
469
+ this.getMinPv = function () {
465
470
  return this.pvMap[`min-${this.priceType}`];
466
471
  };
467
472
 
468
- this.getMaxPv = function() {
473
+ this.getMaxPv = function () {
469
474
  return this.pvMap[`max-${this.priceType}`];
470
475
  };
471
476
 
472
- this.toJSON = function() {
477
+ this.toJSON = function () {
473
478
  let retData = {};
474
479
  retData.sku = this.sku;
475
480
  retData.globalProductID = this.globalProductID;
@@ -538,11 +543,11 @@ const Product = function(productData) {
538
543
  return retData;
539
544
  };
540
545
 
541
- this.setMeCommerceProductData = function(/*productData*/) {
546
+ this.setMeCommerceProductData = function (/*productData*/) {
542
547
  console.error("setMeCommerceProductData is deprecated!");
543
548
  };
544
549
 
545
- this.setBaseUrl = function(baseUrl) {
550
+ this.setBaseUrl = function (baseUrl) {
546
551
  this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
547
552
  this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
548
553
 
@@ -554,7 +559,7 @@ const Product = function(productData) {
554
559
  }
555
560
  };
556
561
 
557
- this.setProductData = function(productData) {
562
+ this.setProductData = function (productData) {
558
563
  let data;
559
564
 
560
565
  if (productData) {
@@ -662,7 +667,7 @@ const Product = function(productData) {
662
667
  ? data.pvMap
663
668
  : this.pvMap;
664
669
  this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
665
- if(data.childSkus) {
670
+ if (data.childSkus) {
666
671
  this.childSkus = data.childSkus;
667
672
  }
668
673
  this.custTypes = data.custTypes || [];
@@ -678,7 +683,7 @@ const Product = function(productData) {
678
683
  }
679
684
  };
680
685
 
681
- this.isEmpty = function() {
686
+ this.isEmpty = function () {
682
687
  return (
683
688
  isFieldEmpty(this.sku) &&
684
689
  isFieldEmpty(this.title) &&
@@ -27,23 +27,11 @@ const ProductData = {
27
27
  },
28
28
 
29
29
  getProductFromEquinox: async function (skus, locale, config) {
30
-
31
- let skuFilter = [];
32
-
33
- if(Array.isArray(skus)) {
34
- skus.forEach((sku) => {
35
- skuFilter.push(`index_key_productId="${sku}" OR index_key_skuId="${sku}"`)
36
- })
37
- } else {
38
- //all featured products
39
- skuFilter.push(`index_key_productId="${skus}" OR index_key_skuId="${skus}"`)
40
- }
41
-
42
- const filter = skuFilter.join(" OR ")
43
- //axios.defaults.withCredentials = true;
30
+ const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
31
+ axios.defaults.withCredentials = true;
44
32
 
45
33
  const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
46
- const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
34
+ const href = `${url}?filter=${encodeURI(filter)}`;
47
35
  const response = await axios.request({
48
36
  method: 'get',
49
37
  url: href,
@@ -52,8 +40,7 @@ const ProductData = {
52
40
  storeId: config.store_id
53
41
  },
54
42
  headers: this.getEquinoxRequestHeaders(),
55
- responseType: 'json',
56
- withCredentials: true
43
+ responseType: 'json'
57
44
  });
58
45
 
59
46
  if (response.data.product) {
@@ -112,7 +99,7 @@ const ProductData = {
112
99
  eqProductVariantMapper: function (eqVariant) {
113
100
 
114
101
  let imageURL = eqVariant.properties.imageURL;
115
- const regex = /\d+\.\d+/
102
+ const regex = /\d+.\d+/
116
103
  let thumbnailImage = ''
117
104
 
118
105
  if (imageURL.includes('contentstack')) {
@@ -268,6 +255,7 @@ const ProductData = {
268
255
  "variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
269
256
  "variantDropdownPlaceholder": "Select Type",
270
257
  "variantsLabel": eqVariant.properties.variantSelectLabel || "",
258
+ "variants": {},
271
259
  "groupOffer": false,
272
260
  "personalOffer": false,
273
261
  "savedEventName": eventName,
@@ -331,9 +319,8 @@ const ProductData = {
331
319
  let variants = {};
332
320
 
333
321
  let prodArr = productDataResponse.map((data) => {
334
- let product = (data.type && data.type === "kit") ? data : data.sku[count];
335
- let imageURL = product.properties.imageURL;
336
- const regex = /\d+\.\d+/
322
+ let imageURL = data.sku[count].properties.imageURL;
323
+ const regex = /\d+.\d+/
337
324
  let thumbnailImage = ''
338
325
 
339
326
  if (imageURL.includes('contentstack')) {
@@ -355,15 +342,15 @@ const ProductData = {
355
342
  eventLabels,
356
343
  computedPrice,
357
344
  defaultProductPrice
358
- } = this.getEqProductPromotions(product);
359
- const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
360
- const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
345
+ } = this.getEqProductPromotions(data.sku[count]);
346
+ const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
347
+ const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
361
348
 
362
349
  prod = {
363
- "sku": product.identifier,
350
+ "sku": data.sku[count].identifier,
364
351
  "globalProductID": data.identifier,
365
352
  "title": data.properties.name,
366
- "country": product.properties.market,
353
+ "country": data.sku[count].properties.market,
367
354
  "language": "en",
368
355
  "shortDescr": data.properties.description,
369
356
  "longDescr": data.properties.productDetailsDescription,
@@ -380,7 +367,7 @@ const ProductData = {
380
367
  "ingredients": data.properties.ingredients,
381
368
  "benefits": data.properties.benefits,
382
369
  "usage": data.properties.usage,
383
- "resources": product.properties.resources,
370
+ "resources": data.sku[count].properties.resources,
384
371
  "videos": "",
385
372
  "movie": "",
386
373
  "youtube": "",
@@ -391,48 +378,48 @@ const ProductData = {
391
378
  }
392
379
  ],
393
380
  "scanQualified": data.properties.scanQualifiedCount,
394
- "availableQuantity": (product.inventoryProperties) ? product.inventoryProperties.atpQty : 0,
381
+ "availableQuantity": data.sku[count].inventoryProperties.atpQty,
395
382
  "maxQuantity": 999,
396
383
  "points": "",
397
- "cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
398
- "pv": product.priceFacets.PV,
384
+ "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
385
+ "pv": data.sku[count].priceFacets.PV,
399
386
  "priceType": "WRTL",
400
387
  "price": discountedPrice,
401
388
  "priceMap": {
402
389
  "WRTL": productPrice,
403
- "WADW-WRTL": product.priceFacets["Regular Price"],
404
- "WADR": product.priceFacets["Regular Price"],
405
- "RTL": product.priceFacets["Regular Price"],
406
- "WADW": product.priceFacets["Wholesale Price"],
407
- "WHL": product.priceFacets["Wholesale Price"],
408
- "WWHL": product.priceFacets["Wholesale Price"]
390
+ "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
391
+ "WADR": data.sku[count].priceFacets["Regular Price"],
392
+ "RTL": data.sku[count].priceFacets["Regular Price"],
393
+ "WADW": data.sku[count].priceFacets["Wholesale Price"],
394
+ "WHL": data.sku[count].priceFacets["Wholesale Price"],
395
+ "WWHL": data.sku[count].priceFacets["Wholesale Price"]
409
396
  },
410
397
  "cvMap": {
411
- "WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
412
- "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
413
- "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
398
+ "WWHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
399
+ "WADW": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
400
+ "WHL": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : ''
414
401
  },
415
402
  "pvMap": {
416
- "WWHL": product.priceFacets.PV,
417
- "WADW": product.priceFacets.PV,
418
- "WHL": product.priceFacets.PV
403
+ "WWHL": data.sku[count].priceFacets.PV,
404
+ "WADW": data.sku[count].priceFacets.PV,
405
+ "WHL": data.sku[count].priceFacets.PV
419
406
  },
420
- "orderTypes": this._setOrderType(product.properties),
407
+ "orderTypes": this._setOrderType(data.sku[count].properties),
421
408
  "childSkus": [],
422
- "custTypes": this.switchCustType(product.properties.customerTypes),
409
+ "custTypes": this.switchCustType(data.sku[count].properties.customerTypes),
423
410
  "division": data.properties.division,
424
411
  "backOrderDate": null,
425
412
  "locallyProduced": false,
426
413
  "agelocme": null,
427
414
  "count": "",
428
415
  "flavor": "",
429
- "size": product.properties.size,
416
+ "size": data.sku[count].properties.size,
430
417
  "shade": "",
431
- "status": this.switchStatusFromEquinox(product.properties.productStatus),
418
+ "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
432
419
  "variantType": "Other",
433
- "variantDropdownLabel": product.properties.variantLabel || "",
420
+ "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
434
421
  "variantDropdownPlaceholder": "Select Type",
435
- "variantsLabel": product.properties.variantLabel || "",
422
+ "variantsLabel": data.sku[count].properties.variantLabel || "",
436
423
  "groupOffer": false,
437
424
  "personalOffer": false,
438
425
  "savedEventName": eventName,
@@ -442,7 +429,7 @@ const ProductData = {
442
429
  "nettoWeight": "",
443
430
  "variants": variants,
444
431
  "searchScore": 0,
445
- "isExclusive": product.properties.isExclusive || false,
432
+ "isExclusive": data.sku[count].properties.isExclusive || false,
446
433
  "marketAttributes": {
447
434
  "discount": true,
448
435
  "redeem": true,
@@ -450,7 +437,7 @@ const ProductData = {
450
437
  },
451
438
  "restrictedMarkets": [],
452
439
  "addOns": [],
453
- "inventory": product.inventory || "", //inventory label
440
+ "inventory": data.sku[count].inventory || "", //inventory label
454
441
  "equinoxProductId": data.identifier
455
442
  };
456
443
  let newProduct = new Product(prod);