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