@nuskin/ns-product-lib 2.5.1-cx24-3377.1 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +19 -13
- package/package.json +3 -3
- package/src/product.js +62 -66
- package/src/productData.js +5 -19
package/CHANGELOG.md
CHANGED
@@ -1,34 +1,40 @@
|
|
1
|
-
## [2.5.1
|
1
|
+
## [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)
|
2
2
|
|
3
3
|
|
4
4
|
### Fix
|
5
5
|
|
6
|
-
*
|
6
|
+
* update getConfiguration call to work with new version of configuration-sdk #CX24-3503 ([8be370e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8be370ebfda910deea01fc562d28c199ed520467)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
7
7
|
|
8
|
-
# [2.
|
8
|
+
# [2.6.0-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3503.1...v2.6.0-cx24-3503.2.1) (2023-03-07)
|
9
9
|
|
10
10
|
|
11
|
-
###
|
11
|
+
### Fix
|
12
12
|
|
13
|
-
*
|
13
|
+
* update dependencies #CX24-3503 ([0ea7523](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0ea752306f8e64d5f73d397d5ddf3cf1839865c3)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
14
|
+
* update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
15
|
+
* update dependencies #CX24-3503 ([dd38c23](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dd38c23b0094dea202fce7c6407c06c917d61676)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
16
|
+
* update dependencies #CX24-3503 ([ca67042](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ca670420a7ed79e7c6fabeb4b7c722abc5811a18)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
17
|
+
* update dependencies #CX24-3503 ([2ac0b65](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2ac0b652f84937d37716e861504ad8c424b20beb)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
18
|
+
* update dependencies #CX24-3503 ([682078f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/682078f703ccb8a0e84a559e828543f31f53ccd8)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
19
|
+
* update dependencies #CX24-3503 ([d48fb1a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d48fb1ac5e29dc7477be7b65522f25a2bbf25250)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
14
20
|
|
15
|
-
|
21
|
+
### Release
|
16
22
|
|
23
|
+
* Automated changes by GitLab pipeline [skip ci] ([fa35816](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa35816ef50672ceaac01173d55615d88cb2c75b))
|
17
24
|
|
18
|
-
|
25
|
+
## [2.5.1-cx24-3503.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0...v2.5.1-cx24-3503.2.1) (2023-03-07)
|
19
26
|
|
20
|
-
* Get test environment if not PROD ([913abb6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/913abb61f8bc6aa8a2cb271d67de08f2f9505c5e))
|
21
27
|
|
22
|
-
|
28
|
+
### Fix
|
23
29
|
|
30
|
+
* update dependencies #CX24-3503 ([53cea8d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/53cea8d5eb39ebaf9ff21b45d2310f02db98e25d)), closes [#CX24-3503](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3503)
|
24
31
|
|
25
|
-
|
32
|
+
# [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)
|
26
33
|
|
27
|
-
* parent product customer types (#CX24-3175) ([411b2cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/411b2cc5a7cf687152dc346579766c8f923b795a)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
|
28
34
|
|
29
|
-
###
|
35
|
+
### New
|
30
36
|
|
31
|
-
*
|
37
|
+
* equinox API integration (#CX24) ([a169d58](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a169d5806f20737fae42d0ebe18a7c746861a4fb)), closes [#CX24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24)
|
32
38
|
|
33
39
|
# [2.5.0-cx24-2179.2.18](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.17...v2.5.0-cx24-2179.2.18) (2023-01-26)
|
34
40
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.5.1
|
3
|
+
"version": "2.5.1",
|
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": "2.2.3",
|
35
35
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
|
-
"@nuskin/ns-util": "
|
36
|
+
"@nuskin/ns-util": "4.2.4",
|
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,81 +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
|
-
}
|
434
|
-
|
430
|
+
this.isBase = function() {
|
435
431
|
return this.sku.substring(2, 4) === "55";
|
436
432
|
};
|
437
433
|
|
438
|
-
this.isVariant = function
|
434
|
+
this.isVariant = function() {
|
439
435
|
return this.baseSku.length > 0 && this.variantSkus().length === 0;
|
440
436
|
};
|
441
437
|
|
442
|
-
this.setVariant = function
|
438
|
+
this.setVariant = function(variantProduct) {
|
443
439
|
if (variantProduct && variantProduct.sku) {
|
444
440
|
this.variants[variantProduct.sku] = variantProduct;
|
445
441
|
}
|
446
442
|
};
|
447
443
|
|
448
|
-
this.getVariant = function
|
444
|
+
this.getVariant = function(sku) {
|
449
445
|
return this.variants[sku];
|
450
446
|
};
|
451
447
|
|
452
|
-
this.variantSkus = function
|
448
|
+
this.variantSkus = function() {
|
453
449
|
return Object.keys(this.variants);
|
454
450
|
};
|
455
451
|
|
456
|
-
this.getVariantsList = function
|
452
|
+
this.getVariantsList = function() {
|
457
453
|
return Object.values(this.variants);
|
458
454
|
};
|
459
455
|
|
460
|
-
this.getMinPrice = function
|
456
|
+
this.getMinPrice = function() {
|
461
457
|
return this.priceMap[`min-${this.priceType}`];
|
462
458
|
};
|
463
459
|
|
464
|
-
this.getMaxPrice = function
|
460
|
+
this.getMaxPrice = function() {
|
465
461
|
return this.priceMap[`max-${this.priceType}`];
|
466
462
|
};
|
467
463
|
|
468
|
-
this.getMinPv = function
|
464
|
+
this.getMinPv = function() {
|
469
465
|
return this.pvMap[`min-${this.priceType}`];
|
470
466
|
};
|
471
467
|
|
472
|
-
this.getMaxPv = function
|
468
|
+
this.getMaxPv = function() {
|
473
469
|
return this.pvMap[`max-${this.priceType}`];
|
474
470
|
};
|
475
471
|
|
476
|
-
this.toJSON = function
|
472
|
+
this.toJSON = function() {
|
477
473
|
let retData = {};
|
478
474
|
retData.sku = this.sku;
|
479
475
|
retData.globalProductID = this.globalProductID;
|
@@ -542,11 +538,11 @@ const Product = function (productData) {
|
|
542
538
|
return retData;
|
543
539
|
};
|
544
540
|
|
545
|
-
this.setMeCommerceProductData = function
|
541
|
+
this.setMeCommerceProductData = function(/*productData*/) {
|
546
542
|
console.error("setMeCommerceProductData is deprecated!");
|
547
543
|
};
|
548
544
|
|
549
|
-
this.setBaseUrl = function
|
545
|
+
this.setBaseUrl = function(baseUrl) {
|
550
546
|
this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
|
551
547
|
this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
|
552
548
|
|
@@ -558,7 +554,7 @@ const Product = function (productData) {
|
|
558
554
|
}
|
559
555
|
};
|
560
556
|
|
561
|
-
this.setProductData = function
|
557
|
+
this.setProductData = function(productData) {
|
562
558
|
let data;
|
563
559
|
|
564
560
|
if (productData) {
|
@@ -666,7 +662,7 @@ const Product = function (productData) {
|
|
666
662
|
? data.pvMap
|
667
663
|
: this.pvMap;
|
668
664
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
|
669
|
-
if
|
665
|
+
if(data.childSkus) {
|
670
666
|
this.childSkus = data.childSkus;
|
671
667
|
}
|
672
668
|
this.custTypes = data.custTypes || [];
|
@@ -682,7 +678,7 @@ const Product = function (productData) {
|
|
682
678
|
}
|
683
679
|
};
|
684
680
|
|
685
|
-
this.isEmpty = function
|
681
|
+
this.isEmpty = function() {
|
686
682
|
return (
|
687
683
|
isFieldEmpty(this.sku) &&
|
688
684
|
isFieldEmpty(this.title) &&
|
package/src/productData.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
const { getConfiguration } = require('@nuskin/configuration-sdk');
|
3
|
-
const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
4
3
|
const axios = require("axios");
|
5
4
|
const contentstack = require('./contentstack/contentstack');
|
6
5
|
const Product = require("./product");
|
@@ -18,14 +17,9 @@ const ProductData = {
|
|
18
17
|
const localeMarket = `${locale}_${market}`;
|
19
18
|
|
20
19
|
if (isEquinoxEnabled) {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
environment: contentstackEnv(),
|
25
|
-
clientId: '735b1eb810304bba966af0891ab54053'
|
26
|
-
}));
|
27
|
-
|
28
|
-
if (config.Equinox_Markets.country_code === market && config.Equinox_Markets.active) {
|
20
|
+
const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
|
21
|
+
|
22
|
+
if (config.country_code === market && config.active) {
|
29
23
|
return await this.getProductFromEquinox(skus, localeMarket, config);
|
30
24
|
}
|
31
25
|
}
|
@@ -36,14 +30,14 @@ const ProductData = {
|
|
36
30
|
const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
|
37
31
|
axios.defaults.withCredentials = true;
|
38
32
|
|
39
|
-
const url = `${config.
|
33
|
+
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
40
34
|
const href = `${url}?filter=${encodeURI(filter)}`;
|
41
35
|
const response = await axios.request({
|
42
36
|
method: 'get',
|
43
37
|
url: href,
|
44
38
|
params: {
|
45
39
|
locale,
|
46
|
-
storeId: config.
|
40
|
+
storeId: config.store_id
|
47
41
|
},
|
48
42
|
headers: this.getEquinoxRequestHeaders(),
|
49
43
|
responseType: 'json'
|
@@ -602,12 +596,4 @@ const ProductData = {
|
|
602
596
|
}
|
603
597
|
}
|
604
598
|
|
605
|
-
function contentstackEnv() {
|
606
|
-
if (typeof window === 'undefined') {
|
607
|
-
return 'test';
|
608
|
-
}
|
609
|
-
|
610
|
-
return (getEnvironmentFromUrl(window.location.host) != "prod") ? "test" : "prod";
|
611
|
-
}
|
612
|
-
|
613
599
|
module.exports = ProductData;
|