@nuskin/ns-product-lib 2.7.0-cx24-3682.26 → 2.7.0-cx24-3702.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -150
- package/package.json +2 -2
- package/src/equinox-helpers/childSKU.js +1 -1
- package/src/equinox-helpers/index.js +31 -173
- package/src/product.js +69 -82
- package/src/productData.js +43 -43
- package/src/equinox-helpers/interceptors/index.js +0 -5
- package/src/equinox-helpers/interceptors/productNotFound.js +0 -72
- package/src/equinox-helpers/mappers/identifier.js +0 -13
- package/src/equinox-helpers/mappers/index.js +0 -13
- package/src/equinox-helpers/mappers/inventoryProperties.js +0 -173
- package/src/equinox-helpers/mappers/properties.js +0 -169
- package/src/equinox-helpers/mappers/variant.js +0 -51
- package/src/equinox-helpers/mappers/variantProperties.js +0 -273
- package/src/equinox-helpers/models/index.js +0 -5
- package/src/equinox-helpers/models/productNotFound.js +0 -48
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(productData) {
|
11
|
+
const Product = function (productData) {
|
12
12
|
this.priceMap = {};
|
13
13
|
this.pvMap = {};
|
14
14
|
this.cvMap = {};
|
@@ -75,22 +75,16 @@ const Product = function(productData) {
|
|
75
75
|
//equinox inventory / stock label
|
76
76
|
//@example "IN STOCK"
|
77
77
|
this.inventory = "";
|
78
|
-
|
79
|
-
// equinox specific properties
|
80
78
|
this.equinoxProductId = "";
|
81
|
-
this.
|
82
|
-
sku: {
|
83
|
-
exists: true
|
84
|
-
}
|
85
|
-
};
|
79
|
+
this.properties = {};
|
86
80
|
|
87
|
-
this.setMarketAttributes = function(productStatus) {
|
81
|
+
this.setMarketAttributes = function (productStatus) {
|
88
82
|
if (productStatus.marketAttributes) {
|
89
83
|
this.marketAttributes = productStatus.marketAttributes;
|
90
84
|
}
|
91
85
|
};
|
92
86
|
|
93
|
-
this.getAgelocmeKeyPart = function() {
|
87
|
+
this.getAgelocmeKeyPart = function () {
|
94
88
|
let keyPart = null;
|
95
89
|
if (this.agelocme) {
|
96
90
|
keyPart =
|
@@ -104,27 +98,27 @@ const Product = function(productData) {
|
|
104
98
|
return keyPart;
|
105
99
|
};
|
106
100
|
|
107
|
-
this.getHighlightedSku = function() {
|
101
|
+
this.getHighlightedSku = function () {
|
108
102
|
let rv = this.sku;
|
109
103
|
if (this.highlightedSku) rv = this.highlightedSku;
|
110
104
|
return rv;
|
111
105
|
};
|
112
106
|
|
113
|
-
this.getProductSearchTitle = function() {
|
107
|
+
this.getProductSearchTitle = function () {
|
114
108
|
if (this.agelocme && this.agelocme.label) {
|
115
109
|
return this.agelocme.label;
|
116
110
|
}
|
117
111
|
return this.title;
|
118
112
|
};
|
119
113
|
|
120
|
-
this.getProductSearchSku = function() {
|
114
|
+
this.getProductSearchSku = function () {
|
121
115
|
if (this.agelocme && this.agelocme.code) {
|
122
116
|
return this.agelocme.code;
|
123
117
|
}
|
124
118
|
return this.getHighlightedSku();
|
125
119
|
};
|
126
120
|
|
127
|
-
this.getDescription = function() {
|
121
|
+
this.getDescription = function () {
|
128
122
|
let description = this.longDescr;
|
129
123
|
if (!description || description.length === 0) {
|
130
124
|
return this.shortDescr;
|
@@ -132,7 +126,7 @@ const Product = function(productData) {
|
|
132
126
|
return description;
|
133
127
|
};
|
134
128
|
|
135
|
-
this.setFullImage = function(fullImage) {
|
129
|
+
this.setFullImage = function (fullImage) {
|
136
130
|
if (fullImage) {
|
137
131
|
this.fullImage = fullImage.replace("http:", "https:");
|
138
132
|
} else {
|
@@ -140,19 +134,19 @@ const Product = function(productData) {
|
|
140
134
|
}
|
141
135
|
};
|
142
136
|
|
143
|
-
this.getFullImage = function() {
|
137
|
+
this.getFullImage = function () {
|
144
138
|
return this.fullImage ? this.fullImage.replace("http:", "https:") : "";
|
145
139
|
};
|
146
140
|
|
147
|
-
this.setProductCarouselImages = function(productCarouselImages) {
|
141
|
+
this.setProductCarouselImages = function (productCarouselImages) {
|
148
142
|
this.productCarouselImages = productCarouselImages;
|
149
143
|
};
|
150
144
|
|
151
|
-
this.getProductCarouselImages = function() {
|
145
|
+
this.getProductCarouselImages = function () {
|
152
146
|
return this.productCarouselImages;
|
153
147
|
};
|
154
148
|
|
155
|
-
this.setImageAltText = function(altText) {
|
149
|
+
this.setImageAltText = function (altText) {
|
156
150
|
if (altText) {
|
157
151
|
this.imageAltText = altText;
|
158
152
|
} else {
|
@@ -160,11 +154,11 @@ const Product = function(productData) {
|
|
160
154
|
}
|
161
155
|
};
|
162
156
|
|
163
|
-
this.getImageAltText = function() {
|
157
|
+
this.getImageAltText = function () {
|
164
158
|
return this.imageAltText || this.title;
|
165
159
|
};
|
166
160
|
|
167
|
-
this.setThumbnail = function(thumbnail) {
|
161
|
+
this.setThumbnail = function (thumbnail) {
|
168
162
|
if (thumbnail) {
|
169
163
|
this.thumbnail = thumbnail.replace("http:", "https:");
|
170
164
|
} else {
|
@@ -172,7 +166,11 @@ const Product = function(productData) {
|
|
172
166
|
}
|
173
167
|
};
|
174
168
|
|
175
|
-
this.
|
169
|
+
this.setEquinoxProductId = function (equinoxProductId) {
|
170
|
+
return this.equinoxProductId = equinoxProductId;
|
171
|
+
}
|
172
|
+
|
173
|
+
this.setThumbnailFromSku = function (sku) {
|
176
174
|
// WARNING: Base URL will need to be handled in the client (call setBaseUrl)
|
177
175
|
// eslint-disable-next-line max-len
|
178
176
|
// this.thumbnail = `${RunConfigService.getBaseUrl()}/content/products/${ProductUtils.getTokenizedSku(sku)}/jcr:content/fullImage.img.100.100.png`;
|
@@ -182,43 +180,43 @@ const Product = function(productData) {
|
|
182
180
|
)}/jcr:content/fullImage.img.100.100.png`;
|
183
181
|
};
|
184
182
|
|
185
|
-
this.getThumbnail = function() {
|
183
|
+
this.getThumbnail = function () {
|
186
184
|
return this.thumbnail ? this.thumbnail.replace("http:", "https:") : "";
|
187
185
|
};
|
188
186
|
|
189
|
-
this.hasAvailableQuantity = function(qty = 1) {
|
187
|
+
this.hasAvailableQuantity = function (qty = 1) {
|
190
188
|
return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
|
191
189
|
};
|
192
190
|
|
193
|
-
this.setPoints = function(points) {
|
191
|
+
this.setPoints = function (points) {
|
194
192
|
this.points = ensureFloatVal(points) || "";
|
195
193
|
};
|
196
194
|
|
197
|
-
this.getPointsFixed = function() {
|
195
|
+
this.getPointsFixed = function () {
|
198
196
|
return parseFloat(this.points).toFixed(2);
|
199
197
|
};
|
200
198
|
|
201
|
-
this.setCv = function(cv) {
|
199
|
+
this.setCv = function (cv) {
|
202
200
|
this.cv = ensureFloatVal(cv) || "";
|
203
201
|
};
|
204
202
|
|
205
|
-
this.getCvFixed = function() {
|
203
|
+
this.getCvFixed = function () {
|
206
204
|
return parseFloat(this.cv).toFixed(2);
|
207
205
|
};
|
208
206
|
|
209
|
-
this.setPv = function(pv) {
|
207
|
+
this.setPv = function (pv) {
|
210
208
|
this.pv = ensureFloatVal(pv) || "";
|
211
209
|
};
|
212
210
|
|
213
|
-
this.getPvFixed = function() {
|
211
|
+
this.getPvFixed = function () {
|
214
212
|
return parseFloat(this.pv || 0).toFixed(2);
|
215
213
|
};
|
216
214
|
|
217
|
-
this.setPrice = function(price) {
|
215
|
+
this.setPrice = function (price) {
|
218
216
|
this.price = ensureFloatVal(price, true);
|
219
217
|
};
|
220
218
|
|
221
|
-
this.setFormattedPrice = function(formattedPrice) {
|
219
|
+
this.setFormattedPrice = function (formattedPrice) {
|
222
220
|
this.formattedPrice = formattedPrice;
|
223
221
|
};
|
224
222
|
|
@@ -227,13 +225,13 @@ const Product = function(productData) {
|
|
227
225
|
* added to the cart the event pricing needs to be remembered if toggling between
|
228
226
|
* pricetypes with event pricing and pricetype without event pricing
|
229
227
|
*/
|
230
|
-
this.lockEventName = function() {
|
228
|
+
this.lockEventName = function () {
|
231
229
|
if (!this.savedEventName && this.eventName) {
|
232
230
|
this.savedEventName = this.eventName;
|
233
231
|
}
|
234
232
|
};
|
235
233
|
|
236
|
-
this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
|
234
|
+
this.setPriceAndPvFromType = function (_priceType, _activeEvents = null, option = {}) {
|
237
235
|
// WARNING: priceType needs to be handled client-side
|
238
236
|
// const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
|
239
237
|
// ? PriceType.WWHL
|
@@ -278,11 +276,11 @@ const Product = function(productData) {
|
|
278
276
|
return changed;
|
279
277
|
};
|
280
278
|
|
281
|
-
this.getPrice = function() {
|
279
|
+
this.getPrice = function () {
|
282
280
|
return this.price ? this.price : 0;
|
283
281
|
};
|
284
282
|
|
285
|
-
this.getPriceFixed = function() {
|
283
|
+
this.getPriceFixed = function () {
|
286
284
|
if (typeof this.price === "number") {
|
287
285
|
return parseFloat(this.price.toFixed(2));
|
288
286
|
} else {
|
@@ -290,15 +288,15 @@ const Product = function(productData) {
|
|
290
288
|
}
|
291
289
|
};
|
292
290
|
|
293
|
-
this.getOriginalPrice = function() {
|
291
|
+
this.getOriginalPrice = function () {
|
294
292
|
return this.priceType ? this.priceMap[this.priceType] : null;
|
295
293
|
};
|
296
294
|
|
297
|
-
this.addPricing = function(type, price) {
|
295
|
+
this.addPricing = function (type, price) {
|
298
296
|
this.priceMap[type] = price;
|
299
297
|
};
|
300
298
|
|
301
|
-
this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
|
299
|
+
this.addPricingFromStatus = function (productStatus, priceType, option = {}) {
|
302
300
|
let modified = false;
|
303
301
|
|
304
302
|
if (!priceType) {
|
@@ -333,7 +331,7 @@ const Product = function(productData) {
|
|
333
331
|
}, this);
|
334
332
|
}
|
335
333
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
|
336
|
-
if(productStatus.childSkus) {
|
334
|
+
if (productStatus.childSkus) {
|
337
335
|
this.childSkus = productStatus.childSkus;
|
338
336
|
}
|
339
337
|
this.setPriceAndPvFromType(priceType, null, option);
|
@@ -353,15 +351,15 @@ const Product = function(productData) {
|
|
353
351
|
return modified;
|
354
352
|
};
|
355
353
|
|
356
|
-
this.addPvWithType = function(type, pv) {
|
354
|
+
this.addPvWithType = function (type, pv) {
|
357
355
|
this.pvMap[type] = pv;
|
358
356
|
};
|
359
357
|
|
360
|
-
this.addCvWithType = function(type, cv) {
|
358
|
+
this.addCvWithType = function (type, cv) {
|
361
359
|
this.cvMap[type] = cv;
|
362
360
|
};
|
363
361
|
|
364
|
-
this.getPricing = function(type) {
|
362
|
+
this.getPricing = function (type) {
|
365
363
|
let retVal = null;
|
366
364
|
|
367
365
|
if (type) {
|
@@ -388,7 +386,7 @@ const Product = function(productData) {
|
|
388
386
|
return eventPriceTypes;
|
389
387
|
};
|
390
388
|
|
391
|
-
this.getPvWithType = function(type) {
|
389
|
+
this.getPvWithType = function (type) {
|
392
390
|
let rv = this.pvMap[type];
|
393
391
|
if (rv == null) {
|
394
392
|
// Assumption: we always have WWHL from the service
|
@@ -398,7 +396,7 @@ const Product = function(productData) {
|
|
398
396
|
return rv;
|
399
397
|
};
|
400
398
|
|
401
|
-
this.getCvWithType = function(type) {
|
399
|
+
this.getCvWithType = function (type) {
|
402
400
|
let rv = this.cvMap[type];
|
403
401
|
if (rv == null) {
|
404
402
|
rv = this.cvMap[PriceType.WWHL];
|
@@ -406,77 +404,77 @@ const Product = function(productData) {
|
|
406
404
|
return rv;
|
407
405
|
};
|
408
406
|
|
409
|
-
this.hasAdrOption = function() {
|
407
|
+
this.hasAdrOption = function () {
|
410
408
|
return this.orderTypes["adr"];
|
411
409
|
};
|
412
410
|
|
413
|
-
this.isAdrOnly = function() {
|
411
|
+
this.isAdrOnly = function () {
|
414
412
|
return this.hasAdrOption() && !this.hasOrderOption();
|
415
413
|
};
|
416
414
|
|
417
|
-
this.hasMultipleOrderTypes = function() {
|
415
|
+
this.hasMultipleOrderTypes = function () {
|
418
416
|
return this.hasOrderOption() && this.hasAdrOption();
|
419
417
|
};
|
420
418
|
|
421
|
-
this.hasOrderOption = function() {
|
419
|
+
this.hasOrderOption = function () {
|
422
420
|
return this.orderTypes["order"];
|
423
421
|
};
|
424
422
|
|
425
|
-
this.isDistributor = function() {
|
423
|
+
this.isDistributor = function () {
|
426
424
|
return this.custTypes.includes("10");
|
427
425
|
};
|
428
426
|
|
429
|
-
this.isCustomer = function() {
|
427
|
+
this.isCustomer = function () {
|
430
428
|
return this.custTypes.includes("20");
|
431
429
|
};
|
432
430
|
|
433
|
-
this.isPreferredCustomer = function() {
|
431
|
+
this.isPreferredCustomer = function () {
|
434
432
|
return this.custTypes.includes("30");
|
435
433
|
};
|
436
434
|
|
437
|
-
this.isBase = function() {
|
435
|
+
this.isBase = function () {
|
438
436
|
return this.sku.substring(2, 4) === "55";
|
439
437
|
};
|
440
438
|
|
441
|
-
this.isVariant = function() {
|
439
|
+
this.isVariant = function () {
|
442
440
|
return this.baseSku.length > 0 && this.variantSkus().length === 0;
|
443
441
|
};
|
444
442
|
|
445
|
-
this.setVariant = function(variantProduct) {
|
443
|
+
this.setVariant = function (variantProduct) {
|
446
444
|
if (variantProduct && variantProduct.sku) {
|
447
445
|
this.variants[variantProduct.sku] = variantProduct;
|
448
446
|
}
|
449
447
|
};
|
450
448
|
|
451
|
-
this.getVariant = function(sku) {
|
449
|
+
this.getVariant = function (sku) {
|
452
450
|
return this.variants[sku];
|
453
451
|
};
|
454
452
|
|
455
|
-
this.variantSkus = function() {
|
453
|
+
this.variantSkus = function () {
|
456
454
|
return Object.keys(this.variants);
|
457
455
|
};
|
458
456
|
|
459
|
-
this.getVariantsList = function() {
|
457
|
+
this.getVariantsList = function () {
|
460
458
|
return Object.values(this.variants);
|
461
459
|
};
|
462
460
|
|
463
|
-
this.getMinPrice = function() {
|
461
|
+
this.getMinPrice = function () {
|
464
462
|
return this.priceMap[`min-${this.priceType}`];
|
465
463
|
};
|
466
464
|
|
467
|
-
this.getMaxPrice = function() {
|
465
|
+
this.getMaxPrice = function () {
|
468
466
|
return this.priceMap[`max-${this.priceType}`];
|
469
467
|
};
|
470
468
|
|
471
|
-
this.getMinPv = function() {
|
469
|
+
this.getMinPv = function () {
|
472
470
|
return this.pvMap[`min-${this.priceType}`];
|
473
471
|
};
|
474
472
|
|
475
|
-
this.getMaxPv = function() {
|
473
|
+
this.getMaxPv = function () {
|
476
474
|
return this.pvMap[`max-${this.priceType}`];
|
477
475
|
};
|
478
476
|
|
479
|
-
this.toJSON = function() {
|
477
|
+
this.toJSON = function () {
|
480
478
|
let retData = {};
|
481
479
|
retData.sku = this.sku;
|
482
480
|
retData.globalProductID = this.globalProductID;
|
@@ -541,20 +539,16 @@ const Product = function(productData) {
|
|
541
539
|
retData.addOns = this.addOns;
|
542
540
|
retData.inventory = this.inventory;
|
543
541
|
retData.equinoxProductId = this.equinoxProductId;
|
544
|
-
retData.
|
545
|
-
sku: {
|
546
|
-
exists: this.equinox.sku.exists
|
547
|
-
}
|
548
|
-
};
|
542
|
+
retData.properties = this.properties;
|
549
543
|
|
550
544
|
return retData;
|
551
545
|
};
|
552
546
|
|
553
|
-
this.setMeCommerceProductData = function(/*productData*/) {
|
547
|
+
this.setMeCommerceProductData = function (/*productData*/) {
|
554
548
|
console.error("setMeCommerceProductData is deprecated!");
|
555
549
|
};
|
556
550
|
|
557
|
-
this.setBaseUrl = function(baseUrl) {
|
551
|
+
this.setBaseUrl = function (baseUrl) {
|
558
552
|
this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
|
559
553
|
this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
|
560
554
|
|
@@ -566,7 +560,7 @@ const Product = function(productData) {
|
|
566
560
|
}
|
567
561
|
};
|
568
562
|
|
569
|
-
this.setProductData = function(productData) {
|
563
|
+
this.setProductData = function (productData) {
|
570
564
|
let data;
|
571
565
|
|
572
566
|
if (productData) {
|
@@ -674,7 +668,7 @@ const Product = function(productData) {
|
|
674
668
|
? data.pvMap
|
675
669
|
: this.pvMap;
|
676
670
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
|
677
|
-
if(data.childSkus) {
|
671
|
+
if (data.childSkus) {
|
678
672
|
this.childSkus = data.childSkus;
|
679
673
|
}
|
680
674
|
this.custTypes = data.custTypes || [];
|
@@ -687,18 +681,11 @@ const Product = function(productData) {
|
|
687
681
|
}
|
688
682
|
|
689
683
|
this.equinoxProductId = data.equinoxProductId;
|
690
|
-
|
691
|
-
if (data.equinox && data.equinox.sku) {
|
692
|
-
this.equinox = {
|
693
|
-
sku: {
|
694
|
-
exists: data.equinox.sku.exists
|
695
|
-
}
|
696
|
-
};
|
697
|
-
}
|
684
|
+
this.properties = data.properties;
|
698
685
|
}
|
699
686
|
};
|
700
687
|
|
701
|
-
this.isEmpty = function() {
|
688
|
+
this.isEmpty = function () {
|
702
689
|
return (
|
703
690
|
isFieldEmpty(this.sku) &&
|
704
691
|
isFieldEmpty(this.title) &&
|
package/src/productData.js
CHANGED
@@ -6,7 +6,6 @@ const Product = require("./product");
|
|
6
6
|
const CustomerTypes = require('./models/customerTypes');
|
7
7
|
const ProductStatus = require("./models/productStatus");
|
8
8
|
const { mapAvailableQuantity, mapChildSKU } = require('./equinox-helpers');
|
9
|
-
const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
|
10
9
|
|
11
10
|
const productTypes = {
|
12
11
|
kit: 'kit'
|
@@ -67,11 +66,9 @@ const ProductData = {
|
|
67
66
|
}
|
68
67
|
|
69
68
|
const filter = skuFilter.join(" OR ")
|
70
|
-
//axios.defaults.withCredentials = true;
|
71
69
|
|
72
70
|
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
73
71
|
const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
|
74
|
-
axios.interceptors.response.use((res) => res, productNotFoundInterceptor);
|
75
72
|
const response = await axios.request({
|
76
73
|
method: 'get',
|
77
74
|
url: href,
|
@@ -84,7 +81,6 @@ const ProductData = {
|
|
84
81
|
withCredentials: true
|
85
82
|
});
|
86
83
|
|
87
|
-
axios.interceptors.response.eject(productNotFoundInterceptor);
|
88
84
|
return response;
|
89
85
|
},
|
90
86
|
|
@@ -136,9 +132,11 @@ const ProductData = {
|
|
136
132
|
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
137
133
|
|
138
134
|
|
139
|
-
const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
|
135
|
+
const { eventName, eventLabels, computedPrice, defaultProductPrice, CVPrice, PVPrice } = this.getEqProductPromotions(eqVariant);
|
140
136
|
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
141
137
|
const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
|
138
|
+
const productCVPrice = eventName ? CVPrice : eqVariant.priceFacets.CV;
|
139
|
+
const productPVPrice = eventName ? PVPrice : eqVariant.priceFacets.PV;
|
142
140
|
|
143
141
|
return {
|
144
142
|
"sku": eqVariant.identifier,
|
@@ -245,8 +243,8 @@ const ProductData = {
|
|
245
243
|
"availableQuantity": eqVariant.inventoryProperties.atpQty,
|
246
244
|
"maxQuantity": 999,
|
247
245
|
"points": "",
|
248
|
-
"cv":
|
249
|
-
"pv":
|
246
|
+
"cv": productCVPrice,
|
247
|
+
"pv": productPVPrice,
|
250
248
|
"priceType": "WRTL",
|
251
249
|
"price": discountedPrice,
|
252
250
|
"priceMap": {
|
@@ -259,14 +257,14 @@ const ProductData = {
|
|
259
257
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
260
258
|
},
|
261
259
|
"cvMap": {
|
262
|
-
"WWHL":
|
263
|
-
"WADW":
|
264
|
-
"WHL":
|
260
|
+
"WWHL": productCVPrice,
|
261
|
+
"WADW": productCVPrice,
|
262
|
+
"WHL": productCVPrice
|
265
263
|
},
|
266
264
|
"pvMap": {
|
267
|
-
"WWHL":
|
268
|
-
"WADW":
|
269
|
-
"WHL":
|
265
|
+
"WWHL": productPVPrice,
|
266
|
+
"WADW": productPVPrice,
|
267
|
+
"WHL": productPVPrice
|
270
268
|
},
|
271
269
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
272
270
|
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
@@ -278,7 +276,7 @@ const ProductData = {
|
|
278
276
|
"flavor": "",
|
279
277
|
"size": eqVariant.properties.size,
|
280
278
|
"shade": "",
|
281
|
-
"status": this.switchStatusFromEquinox(eqVariant.properties.
|
279
|
+
"status": this.switchStatusFromEquinox(eqVariant.properties.productStatus),
|
282
280
|
"variantType": "Other",
|
283
281
|
"variantDropdownLabel": eqVariant.properties.variantLabel || "",
|
284
282
|
"variantDropdownPlaceholder": "Select Type",
|
@@ -299,7 +297,8 @@ const ProductData = {
|
|
299
297
|
},
|
300
298
|
"restrictedMarkets": [],
|
301
299
|
"addOns": [],
|
302
|
-
"equinoxProductId": eqVariant.identifier
|
300
|
+
"equinoxProductId": eqVariant.identifier,
|
301
|
+
"properties": eqVariant.properties
|
303
302
|
};
|
304
303
|
},
|
305
304
|
|
@@ -323,6 +322,16 @@ const ProductData = {
|
|
323
322
|
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
|
324
323
|
? product.totalValue.priceAfterDiscount
|
325
324
|
: 0;
|
325
|
+
|
326
|
+
let CVPrice = 0,
|
327
|
+
PVPrice = 0;
|
328
|
+
|
329
|
+
if (product.totalValue && product.totalValue.priceFacets) {
|
330
|
+
const productPriceFacets = product.totalValue.priceFacets;
|
331
|
+
CVPrice = productPriceFacets.CV && productPriceFacets.CV.CVAfterDiscount ? productPriceFacets.CV.CVAfterDiscount : 0;
|
332
|
+
PVPrice = productPriceFacets.PV && productPriceFacets.PV.PVAfterDiscount ? productPriceFacets.PV.PVAfterDiscount : 0;
|
333
|
+
}
|
334
|
+
|
326
335
|
let eventName = "";
|
327
336
|
const eventLabels = [];
|
328
337
|
|
@@ -336,17 +345,19 @@ const ProductData = {
|
|
336
345
|
eventLabels: eventLabels.join(','),
|
337
346
|
defaultProductPrice,
|
338
347
|
computedPrice,
|
339
|
-
eventName
|
348
|
+
eventName,
|
349
|
+
CVPrice,
|
350
|
+
PVPrice
|
340
351
|
}
|
341
352
|
},
|
342
353
|
|
343
354
|
eqProductMapper: async function (productDataResponse, skus) {
|
344
355
|
let count = 0;
|
345
|
-
let variants = {};
|
346
356
|
const products = [];
|
347
357
|
|
348
358
|
for (const productData of productDataResponse) {
|
349
359
|
try {
|
360
|
+
let variants = {};
|
350
361
|
let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
|
351
362
|
let imageURL = product.properties.imageURL ? product.properties.imageURL : '';
|
352
363
|
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
@@ -364,10 +375,14 @@ const ProductData = {
|
|
364
375
|
eventName,
|
365
376
|
eventLabels,
|
366
377
|
computedPrice,
|
367
|
-
defaultProductPrice
|
378
|
+
defaultProductPrice,
|
379
|
+
CVPrice,
|
380
|
+
PVPrice
|
368
381
|
} = this.getEqProductPromotions(product);
|
369
382
|
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
370
383
|
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
384
|
+
const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
|
385
|
+
const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
|
371
386
|
|
372
387
|
product.childSkus = await this.fetchChildSkus(product);
|
373
388
|
product.availableQuantity = mapAvailableQuantity(product);
|
@@ -406,8 +421,8 @@ const ProductData = {
|
|
406
421
|
"scanQualified": productData.properties.scanQualifiedCount,
|
407
422
|
"maxQuantity": 999,
|
408
423
|
"points": "",
|
409
|
-
"cv":
|
410
|
-
"pv":
|
424
|
+
"cv": productCVPrice,
|
425
|
+
"pv": productPVPrice,
|
411
426
|
"priceType": "WRTL",
|
412
427
|
"price": discountedPrice,
|
413
428
|
"priceMap": {
|
@@ -420,14 +435,14 @@ const ProductData = {
|
|
420
435
|
"WWHL": product.priceFacets["Wholesale Price"]
|
421
436
|
},
|
422
437
|
"cvMap": {
|
423
|
-
"WWHL":
|
424
|
-
"WADW":
|
425
|
-
"WHL":
|
438
|
+
"WWHL": productCVPrice,
|
439
|
+
"WADW": productCVPrice,
|
440
|
+
"WHL": productCVPrice
|
426
441
|
},
|
427
442
|
"pvMap": {
|
428
|
-
"WWHL":
|
429
|
-
"WADW":
|
430
|
-
"WHL":
|
443
|
+
"WWHL": productPVPrice,
|
444
|
+
"WADW": productPVPrice,
|
445
|
+
"WHL": productPVPrice
|
431
446
|
},
|
432
447
|
"orderTypes": this._setOrderType(product.properties),
|
433
448
|
"custTypes": this.switchCustType(product.properties.customerTypes),
|
@@ -443,7 +458,7 @@ const ProductData = {
|
|
443
458
|
"variantType": "Other",
|
444
459
|
"variantDropdownLabel": product.properties.variantLabel || "",
|
445
460
|
"variantDropdownPlaceholder": "Select Type",
|
446
|
-
"variantsLabel": product.properties.
|
461
|
+
"variantsLabel": product.properties.variantSelectLabel || "",
|
447
462
|
"groupOffer": false,
|
448
463
|
"personalOffer": false,
|
449
464
|
"savedEventName": eventName,
|
@@ -463,11 +478,7 @@ const ProductData = {
|
|
463
478
|
"addOns": [],
|
464
479
|
"inventory": product.inventory || "", //inventory label
|
465
480
|
"equinoxProductId": productData.identifier,
|
466
|
-
|
467
|
-
sku: {
|
468
|
-
exists: this.mapEquinoxSKUExists(productData.exists)
|
469
|
-
}
|
470
|
-
}
|
481
|
+
"properties": product.properties
|
471
482
|
};
|
472
483
|
|
473
484
|
products.push(new Product(product));
|
@@ -491,17 +502,6 @@ const ProductData = {
|
|
491
502
|
};
|
492
503
|
},
|
493
504
|
|
494
|
-
mapEquinoxSKUExists: function(exists) {
|
495
|
-
// this could be avoided if only we are using response mapper
|
496
|
-
// for equinox products that exists.
|
497
|
-
// @todo: clean-up
|
498
|
-
if (exists === undefined) {
|
499
|
-
return true;
|
500
|
-
}
|
501
|
-
|
502
|
-
return exists;
|
503
|
-
},
|
504
|
-
|
505
505
|
/**
|
506
506
|
* fetchChildSkus make requests to Equinox to get the SKUs of a kit.
|
507
507
|
* @param {*} product
|