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