@nuskin/ns-product-lib 2.6.0-cx24-3503.2 → 2.6.0-cx24-3372.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +34 -7
- package/package.json +3 -3
- package/src/product.js +62 -65
- package/src/productData.js +51 -38
package/CHANGELOG.md
CHANGED
@@ -1,18 +1,45 @@
|
|
1
|
-
# [2.6.0-cx24-
|
1
|
+
# [2.6.0-cx24-3372.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.5...v2.6.0-cx24-3372.6) (2023-03-06)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* Query for product equinox search ([7f873a5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7f873a56cb579c68d7665947a2c5f9615eeb2101))
|
7
|
+
|
8
|
+
# [2.6.0-cx24-3372.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.4...v2.6.0-cx24-3372.5) (2023-03-02)
|
2
9
|
|
3
10
|
|
4
11
|
### Fix
|
5
12
|
|
6
|
-
*
|
13
|
+
* inventoryProperties atpQty ([3b271aa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b271aa16960fbaaa2a68c08a2d1d1c93d54ec15))
|
7
14
|
|
8
|
-
# [2.6.0-cx24-
|
15
|
+
# [2.6.0-cx24-3372.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.3...v2.6.0-cx24-3372.4) (2023-03-02)
|
9
16
|
|
10
17
|
|
11
|
-
###
|
18
|
+
### Fix
|
19
|
+
|
20
|
+
* inventoryProperties atpQty ([60ec521](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60ec521223367abcd9570969c0e65522f76afe43))
|
21
|
+
|
22
|
+
# [2.6.0-cx24-3372.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.2...v2.6.0-cx24-3372.3) (2023-03-02)
|
23
|
+
|
24
|
+
|
25
|
+
### Fix
|
26
|
+
|
27
|
+
* Kit mapping ([af76396](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/af76396940d95988bbcfad73fc047381945847bb))
|
28
|
+
|
29
|
+
# [2.6.0-cx24-3372.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3372.1...v2.6.0-cx24-3372.2) (2023-03-01)
|
30
|
+
|
31
|
+
|
32
|
+
### New
|
33
|
+
|
34
|
+
* Product Kit API search ([4260768](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/426076856ed7d1d90f536fc249d84e1bd88e2d12))
|
35
|
+
|
36
|
+
# [2.6.0-cx24-3372.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.6.0-cx24-3372.1) (2023-03-01)
|
37
|
+
|
38
|
+
|
39
|
+
### New
|
12
40
|
|
13
|
-
*
|
14
|
-
*
|
15
|
-
* use latest version of configuration-sdk and ns-util (CX24-3503) ([d343dbf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d343dbfcd5b4d946746576f84ae5157bcef403ea))
|
41
|
+
* Product Kit API search ([0d69d93](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0d69d931b989ccc250b698148c78db17a003bc13))
|
42
|
+
* Product Kit API search ([d549e15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d549e15fa7c967d1b2bbede6d3c2695ecc66265c))
|
16
43
|
|
17
44
|
# [2.5.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.5.0) (2023-02-22)
|
18
45
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.6.0-cx24-
|
3
|
+
"version": "2.6.0-cx24-3372.6",
|
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,9 +31,9 @@
|
|
31
31
|
"prettier": "1.19.1"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@nuskin/configuration-sdk": "
|
34
|
+
"@nuskin/configuration-sdk": "1.0.1",
|
35
35
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
|
-
"@nuskin/ns-util": "
|
36
|
+
"@nuskin/ns-util": "3.107.0",
|
37
37
|
"axios": "0.27.2",
|
38
38
|
"qs": "6.11.0"
|
39
39
|
},
|
package/src/product.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const { isTrue }
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
182
|
+
this.hasAvailableQuantity = function(qty = 1) {
|
183
183
|
return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
|
184
184
|
};
|
185
185
|
|
186
|
-
this.setPoints = function
|
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
|
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
|
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
|
210
|
+
this.setPrice = function(price) {
|
211
211
|
this.price = ensureFloatVal(price, true);
|
212
212
|
};
|
213
213
|
|
214
|
-
this.setFormattedPrice = function
|
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
|
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
|
290
|
+
this.addPricing = function(type, price) {
|
291
291
|
this.priceMap[type] = price;
|
292
292
|
};
|
293
293
|
|
294
|
-
this.addPricingFromStatus = function
|
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
|
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
|
349
|
+
this.addPvWithType = function(type, pv) {
|
350
350
|
this.pvMap[type] = pv;
|
351
351
|
};
|
352
352
|
|
353
|
-
this.addCvWithType = function
|
353
|
+
this.addCvWithType = function(type, cv) {
|
354
354
|
this.cvMap[type] = cv;
|
355
355
|
};
|
356
356
|
|
357
|
-
this.getPricing = function
|
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
|
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
|
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,80 +399,77 @@ 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
|
431
|
-
if (option && option.isEquinoxEnabled) {
|
432
|
-
return !!this.variants;
|
433
|
-
}
|
430
|
+
this.isBase = function() {
|
434
431
|
return this.sku.substring(2, 4) === "55";
|
435
432
|
};
|
436
433
|
|
437
|
-
this.isVariant = function
|
434
|
+
this.isVariant = function() {
|
438
435
|
return this.baseSku.length > 0 && this.variantSkus().length === 0;
|
439
436
|
};
|
440
437
|
|
441
|
-
this.setVariant = function
|
438
|
+
this.setVariant = function(variantProduct) {
|
442
439
|
if (variantProduct && variantProduct.sku) {
|
443
440
|
this.variants[variantProduct.sku] = variantProduct;
|
444
441
|
}
|
445
442
|
};
|
446
443
|
|
447
|
-
this.getVariant = function
|
444
|
+
this.getVariant = function(sku) {
|
448
445
|
return this.variants[sku];
|
449
446
|
};
|
450
447
|
|
451
|
-
this.variantSkus = function
|
448
|
+
this.variantSkus = function() {
|
452
449
|
return Object.keys(this.variants);
|
453
450
|
};
|
454
451
|
|
455
|
-
this.getVariantsList = function
|
452
|
+
this.getVariantsList = function() {
|
456
453
|
return Object.values(this.variants);
|
457
454
|
};
|
458
455
|
|
459
|
-
this.getMinPrice = function
|
456
|
+
this.getMinPrice = function() {
|
460
457
|
return this.priceMap[`min-${this.priceType}`];
|
461
458
|
};
|
462
459
|
|
463
|
-
this.getMaxPrice = function
|
460
|
+
this.getMaxPrice = function() {
|
464
461
|
return this.priceMap[`max-${this.priceType}`];
|
465
462
|
};
|
466
463
|
|
467
|
-
this.getMinPv = function
|
464
|
+
this.getMinPv = function() {
|
468
465
|
return this.pvMap[`min-${this.priceType}`];
|
469
466
|
};
|
470
467
|
|
471
|
-
this.getMaxPv = function
|
468
|
+
this.getMaxPv = function() {
|
472
469
|
return this.pvMap[`max-${this.priceType}`];
|
473
470
|
};
|
474
471
|
|
475
|
-
this.toJSON = function
|
472
|
+
this.toJSON = function() {
|
476
473
|
let retData = {};
|
477
474
|
retData.sku = this.sku;
|
478
475
|
retData.globalProductID = this.globalProductID;
|
@@ -541,11 +538,11 @@ const Product = function (productData) {
|
|
541
538
|
return retData;
|
542
539
|
};
|
543
540
|
|
544
|
-
this.setMeCommerceProductData = function
|
541
|
+
this.setMeCommerceProductData = function(/*productData*/) {
|
545
542
|
console.error("setMeCommerceProductData is deprecated!");
|
546
543
|
};
|
547
544
|
|
548
|
-
this.setBaseUrl = function
|
545
|
+
this.setBaseUrl = function(baseUrl) {
|
549
546
|
this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
|
550
547
|
this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
|
551
548
|
|
@@ -557,7 +554,7 @@ const Product = function (productData) {
|
|
557
554
|
}
|
558
555
|
};
|
559
556
|
|
560
|
-
this.setProductData = function
|
557
|
+
this.setProductData = function(productData) {
|
561
558
|
let data;
|
562
559
|
|
563
560
|
if (productData) {
|
@@ -665,7 +662,7 @@ const Product = function (productData) {
|
|
665
662
|
? data.pvMap
|
666
663
|
: this.pvMap;
|
667
664
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
|
668
|
-
if
|
665
|
+
if(data.childSkus) {
|
669
666
|
this.childSkus = data.childSkus;
|
670
667
|
}
|
671
668
|
this.custTypes = data.custTypes || [];
|
@@ -681,7 +678,7 @@ const Product = function (productData) {
|
|
681
678
|
}
|
682
679
|
};
|
683
680
|
|
684
|
-
this.isEmpty = function
|
681
|
+
this.isEmpty = function() {
|
685
682
|
return (
|
686
683
|
isFieldEmpty(this.sku) &&
|
687
684
|
isFieldEmpty(this.title) &&
|
package/src/productData.js
CHANGED
@@ -18,14 +18,14 @@ const ProductData = {
|
|
18
18
|
const localeMarket = `${locale}_${market}`;
|
19
19
|
|
20
20
|
if (isEquinoxEnabled) {
|
21
|
-
|
21
|
+
let config = (await getConfiguration({
|
22
|
+
configMapNames: ['Equinox_Markets'],
|
22
23
|
country: market,
|
23
24
|
environment: contentstackEnv(),
|
24
25
|
clientId: '735b1eb810304bba966af0891ab54053'
|
25
|
-
};
|
26
|
-
const config = (await getConfiguration(['Equinox_Markets'], options)).Equinox_Markets;
|
26
|
+
}));
|
27
27
|
|
28
|
-
if (config.country_code === market && config.active) {
|
28
|
+
if (config.Equinox_Markets.country_code === market && config.Equinox_Markets.active) {
|
29
29
|
return await this.getProductFromEquinox(skus, localeMarket, config);
|
30
30
|
}
|
31
31
|
}
|
@@ -33,17 +33,29 @@ const ProductData = {
|
|
33
33
|
},
|
34
34
|
|
35
35
|
getProductFromEquinox: async function (skus, locale, config) {
|
36
|
-
|
36
|
+
|
37
|
+
let skuFilter = [];
|
38
|
+
|
39
|
+
if(Array.isArray(skus)) {
|
40
|
+
skus.forEach((sku) => {
|
41
|
+
skuFilter.push(`index_key_productId="${sku}" OR index_key_skuId="${sku}"`)
|
42
|
+
})
|
43
|
+
} else {
|
44
|
+
//all featured products
|
45
|
+
skuFilter.push(`index_key_productId="${skus}" OR index_key_skuId="${skus}"`)
|
46
|
+
}
|
47
|
+
|
48
|
+
const filter = skuFilter.join(" OR ")
|
37
49
|
axios.defaults.withCredentials = true;
|
38
50
|
|
39
|
-
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
40
|
-
const href = `${url}?filter
|
51
|
+
const url = `${config.Equinox_Markets.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
52
|
+
const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
|
41
53
|
const response = await axios.request({
|
42
54
|
method: 'get',
|
43
55
|
url: href,
|
44
56
|
params: {
|
45
57
|
locale,
|
46
|
-
storeId: config.store_id
|
58
|
+
storeId: config.Equinox_Markets.store_id
|
47
59
|
},
|
48
60
|
headers: this.getEquinoxRequestHeaders(),
|
49
61
|
responseType: 'json'
|
@@ -324,7 +336,8 @@ const ProductData = {
|
|
324
336
|
let variants = {};
|
325
337
|
|
326
338
|
let prodArr = productDataResponse.map((data) => {
|
327
|
-
let
|
339
|
+
let product = (data.type && data.type === "kit") ? data : data.sku[count];
|
340
|
+
let imageURL = product.properties.imageURL;
|
328
341
|
const regex = /\d+.\d+/
|
329
342
|
let thumbnailImage = ''
|
330
343
|
|
@@ -347,15 +360,15 @@ const ProductData = {
|
|
347
360
|
eventLabels,
|
348
361
|
computedPrice,
|
349
362
|
defaultProductPrice
|
350
|
-
} = this.getEqProductPromotions(
|
351
|
-
const productPrice = eventName ? defaultProductPrice :
|
352
|
-
const discountedPrice = eventName ? computedPrice :
|
363
|
+
} = this.getEqProductPromotions(product);
|
364
|
+
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
365
|
+
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
353
366
|
|
354
367
|
prod = {
|
355
|
-
"sku":
|
368
|
+
"sku": product.identifier,
|
356
369
|
"globalProductID": data.identifier,
|
357
370
|
"title": data.properties.name,
|
358
|
-
"country":
|
371
|
+
"country": product.properties.market,
|
359
372
|
"language": "en",
|
360
373
|
"shortDescr": data.properties.description,
|
361
374
|
"longDescr": data.properties.productDetailsDescription,
|
@@ -372,7 +385,7 @@ const ProductData = {
|
|
372
385
|
"ingredients": data.properties.ingredients,
|
373
386
|
"benefits": data.properties.benefits,
|
374
387
|
"usage": data.properties.usage,
|
375
|
-
"resources":
|
388
|
+
"resources": product.properties.resources,
|
376
389
|
"videos": "",
|
377
390
|
"movie": "",
|
378
391
|
"youtube": "",
|
@@ -383,48 +396,48 @@ const ProductData = {
|
|
383
396
|
}
|
384
397
|
],
|
385
398
|
"scanQualified": data.properties.scanQualifiedCount,
|
386
|
-
"availableQuantity":
|
399
|
+
"availableQuantity": (product.inventoryProperties) ? product.inventoryProperties.atpQty : 0,
|
387
400
|
"maxQuantity": 999,
|
388
401
|
"points": "",
|
389
|
-
"cv": (
|
390
|
-
"pv":
|
402
|
+
"cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
403
|
+
"pv": product.priceFacets.PV,
|
391
404
|
"priceType": "WRTL",
|
392
405
|
"price": discountedPrice,
|
393
406
|
"priceMap": {
|
394
407
|
"WRTL": productPrice,
|
395
|
-
"WADW-WRTL":
|
396
|
-
"WADR":
|
397
|
-
"RTL":
|
398
|
-
"WADW":
|
399
|
-
"WHL":
|
400
|
-
"WWHL":
|
408
|
+
"WADW-WRTL": product.priceFacets["Regular Price"],
|
409
|
+
"WADR": product.priceFacets["Regular Price"],
|
410
|
+
"RTL": product.priceFacets["Regular Price"],
|
411
|
+
"WADW": product.priceFacets["Wholesale Price"],
|
412
|
+
"WHL": product.priceFacets["Wholesale Price"],
|
413
|
+
"WWHL": product.priceFacets["Wholesale Price"]
|
401
414
|
},
|
402
415
|
"cvMap": {
|
403
|
-
"WWHL": (
|
404
|
-
"WADW": (
|
405
|
-
"WHL": (
|
416
|
+
"WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
417
|
+
"WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
418
|
+
"WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
|
406
419
|
},
|
407
420
|
"pvMap": {
|
408
|
-
"WWHL":
|
409
|
-
"WADW":
|
410
|
-
"WHL":
|
421
|
+
"WWHL": product.priceFacets.PV,
|
422
|
+
"WADW": product.priceFacets.PV,
|
423
|
+
"WHL": product.priceFacets.PV
|
411
424
|
},
|
412
|
-
"orderTypes": this._setOrderType(
|
425
|
+
"orderTypes": this._setOrderType(product.properties),
|
413
426
|
"childSkus": [],
|
414
|
-
"custTypes": this.switchCustType(
|
427
|
+
"custTypes": this.switchCustType(product.properties.customerTypes),
|
415
428
|
"division": data.properties.division,
|
416
429
|
"backOrderDate": null,
|
417
430
|
"locallyProduced": false,
|
418
431
|
"agelocme": null,
|
419
432
|
"count": "",
|
420
433
|
"flavor": "",
|
421
|
-
"size":
|
434
|
+
"size": product.properties.size,
|
422
435
|
"shade": "",
|
423
|
-
"status": this.switchStatusFromEquinox(
|
436
|
+
"status": this.switchStatusFromEquinox(product.properties.productStatus),
|
424
437
|
"variantType": "Other",
|
425
|
-
"variantDropdownLabel":
|
438
|
+
"variantDropdownLabel": product.properties.variantLabel || "",
|
426
439
|
"variantDropdownPlaceholder": "Select Type",
|
427
|
-
"variantsLabel":
|
440
|
+
"variantsLabel": product.properties.variantLabel || "",
|
428
441
|
"groupOffer": false,
|
429
442
|
"personalOffer": false,
|
430
443
|
"savedEventName": eventName,
|
@@ -434,7 +447,7 @@ const ProductData = {
|
|
434
447
|
"nettoWeight": "",
|
435
448
|
"variants": variants,
|
436
449
|
"searchScore": 0,
|
437
|
-
"isExclusive":
|
450
|
+
"isExclusive": product.properties.isExclusive || false,
|
438
451
|
"marketAttributes": {
|
439
452
|
"discount": true,
|
440
453
|
"redeem": true,
|
@@ -442,7 +455,7 @@ const ProductData = {
|
|
442
455
|
},
|
443
456
|
"restrictedMarkets": [],
|
444
457
|
"addOns": [],
|
445
|
-
"inventory":
|
458
|
+
"inventory": product.inventory || "", //inventory label
|
446
459
|
"equinoxProductId": data.identifier
|
447
460
|
};
|
448
461
|
let newProduct = new Product(prod);
|