@nuskin/ns-product-lib 2.5.0-cx24-2179.2.10 → 2.5.0-cx24-3175.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -102
- package/package.json +1 -2
- package/src/contentstack/contentstack.js +5 -5
- package/src/index.js +2 -2
- package/src/models/customerTypes.js +16 -0
- package/src/{priceType.js → models/priceType.js} +0 -0
- package/src/{productStatus.js → models/productStatus.js} +7 -0
- package/src/product.js +9 -22
- package/src/productData.js +99 -183
package/CHANGELOG.md
CHANGED
@@ -1,109 +1,11 @@
|
|
1
|
-
# [2.5.0-cx24-
|
2
|
-
|
3
|
-
|
4
|
-
### Fix
|
5
|
-
|
6
|
-
* Equinox API called for non equinox market (CX24-3168) ([399e615](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/399e6150914dcafd5bd9fcd7ca0e0a95b65656d7))
|
7
|
-
|
8
|
-
# [2.5.0-cx24-2179.2.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.8...v2.5.0-cx24-2179.2.9) (2022-12-20)
|
9
|
-
|
10
|
-
|
11
|
-
### Fix
|
12
|
-
|
13
|
-
* eq market event pricing and name (#CX24-2179) ([213b59a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/213b59a33a208ffad0a6726521ce7f365d34d36e)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
14
|
-
* Slow response of add-to-cart button function for Equinox Cart ([14394b2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/14394b299afbd53254a3ec053ad41e68ed526dfe))
|
15
|
-
* Unit Tests ([ace52c6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ace52c6418991d0263a1e1f8d99901e724abf923))
|
16
|
-
|
17
|
-
### Release
|
18
|
-
|
19
|
-
* Automated changes by GitLab pipeline [skip ci] ([eb755fa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/eb755fae1e1f1f221a34d92f5ff4e64787a4132d))
|
20
|
-
* Automated changes by GitLab pipeline [skip ci] ([6a75f7a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6a75f7a5f8b2f3b17e4d7387af37cad4f367b45c))
|
21
|
-
|
22
|
-
### Update
|
23
|
-
|
24
|
-
* use configuration-sdk to pull the configurations (CX24-2931) ([6934570](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/69345701e6b44754ffeb648ead56f0288aadeb16))
|
25
|
-
|
26
|
-
# [2.5.0-CX24.3.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-CX24.3.1) (2022-12-06)
|
27
|
-
|
28
|
-
* added eq promoion bypass for setPriceAndPvFromType v5 (#CX24-2179) ([f5b62e5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f5b62e5e82f1830d4105ffc965b64e9a7fc88d9b)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
29
|
-
|
30
|
-
# [2.5.0-cx24-2179.2.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.5...v2.5.0-cx24-2179.2.6) (2022-12-05)
|
31
|
-
|
32
|
-
|
33
|
-
### New
|
34
|
-
|
35
|
-
* added eq promoion bypass for setPriceAndPvFromType v4 (#CX24-2179) ([abcdd30](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/abcdd30223107786c0c2f9d1a8946053ef6dcef5)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
36
|
-
|
37
|
-
# [2.5.0-cx24-2179.2.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.4...v2.5.0-cx24-2179.2.5) (2022-12-05)
|
38
|
-
|
39
|
-
|
40
|
-
### New
|
41
|
-
|
42
|
-
* added eq promoion bypass for setPriceAndPvFromType v3 (#CX24-2179) ([79fe156](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/79fe1562d0cafc44f8945e57c316c8ba0b55a88b)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
43
|
-
|
44
|
-
# [2.5.0-cx24-2179.2.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.3...v2.5.0-cx24-2179.2.4) (2022-12-05)
|
45
|
-
|
46
|
-
|
47
|
-
### New
|
48
|
-
|
49
|
-
* added eq promoion bypass for setPriceAndPvFromType v2 (#CX24-2179) ([25bde9a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/25bde9a8e19b1e4e44e37457dfb087e0a6212ee1)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
50
|
-
|
51
|
-
# [2.5.0-cx24-2179.2.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.2...v2.5.0-cx24-2179.2.3) (2022-12-05)
|
52
|
-
|
53
|
-
|
54
|
-
### New
|
55
|
-
|
56
|
-
* added eq promoion bypass for setPriceAndPvFromType (#CX24-2179) ([716cefc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/716cefc2a2522287e017709a8b2cfef5a7ce5e07)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
57
|
-
|
58
|
-
# [2.5.0-cx24-2179.2.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.1...v2.5.0-cx24-2179.2.2) (2022-12-05)
|
59
|
-
|
60
|
-
|
61
|
-
### New
|
62
|
-
|
63
|
-
* added eq promotion support- debug sales event (#CX24-2179) ([992a2cf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/992a2cfb178b3e12a6b8a0229ae5f6f607fb41d3)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
|
64
|
-
|
65
|
-
# [2.5.0-cx24-2179.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-cx24-2179.2.1) (2022-12-02)
|
66
|
-
>>>>>>> CX24.2
|
67
|
-
|
68
|
-
|
69
|
-
### Fix
|
70
|
-
|
71
|
-
* [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([a89af4a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a89af4a5d00c6a68fcaeff22f128554270add21e))
|
72
|
-
|
73
|
-
### Release
|
74
|
-
|
75
|
-
* Automated changes by GitLab pipeline [skip ci] ([07bfa40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/07bfa404c552c05637c2c8a537c4ff298536874e))
|
76
|
-
* Automated changes by GitLab pipeline [skip ci] ([fa1c0d9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa1c0d9d5853482e3ac49cea4e99599e7192f85b))
|
77
|
-
* Automated changes by GitLab pipeline [skip ci] ([2d20787](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2d2078763b2d57edb8a24f438ac90dd37c3ff41b))
|
78
|
-
|
79
|
-
### Update
|
80
|
-
|
81
|
-
* set ADR pricing from equinox (CX24-2862) ([65d04d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65d04d2e9ff4018edfe99e5a7412bee985d3def2))
|
82
|
-
* set ADR pricing from equinox (CX24-2862) ([54a5693](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/54a56932e5df36c9c30ce6358d8597c98be3d20d))
|
83
|
-
* set ADR pricing from equinox (CX24-2862) ([bbd135f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bbd135f1ed0395c578be2274c84ba136ceed9376))
|
84
|
-
* set ADR pricing from equinox (CX24-2862) ([197003e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/197003e1629bd394c547a118d332b5e8574dfc7d))
|
85
|
-
|
86
|
-
# [2.5.0-cx24-2862.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2862.1...v2.5.0-cx24-2862.2) (2022-11-11)
|
87
|
-
|
88
|
-
|
89
|
-
### Update
|
90
|
-
|
91
|
-
* set ADR pricing from equinox (CX24-2862) ([b64dcea](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b64dcea4dd3374be992c667db5c0b2604aacc029))
|
92
|
-
|
93
|
-
# [2.5.0-cx24-2862.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-cx24-2612.1.1...v2.5.0-cx24-2862.1) (2022-11-10)
|
1
|
+
# [2.5.0-cx24-3175.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.5.0-cx24-3175.1) (2023-01-20)
|
94
2
|
|
95
3
|
|
96
4
|
### Update
|
97
5
|
|
98
|
-
*
|
99
|
-
*
|
100
|
-
|
101
|
-
## [2.4.2-cx24-2612.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-cx24-2612.1.1) (2022-11-07)
|
102
|
-
|
103
|
-
|
104
|
-
### Fix
|
105
|
-
|
106
|
-
* [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([9d9d106](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9d9d10667477b4c7ef7bf8ec013aab322d3cdbcc))
|
6
|
+
* remapped equinox isExclusive field (#CX24-3175) ([6adcee1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6adcee103ca720697152d253c135546af7393739)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
|
7
|
+
* remapped equinox properties after migration (#CX24-3175) ([cd1e3f6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cd1e3f6894b764283b026197412a6d1859b35a91)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
|
8
|
+
* remapped equinox variant label property (#CX24-3175) ([3c2a7dc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3c2a7dc4c9543577ae6a90f3f5df0f092707e2b6)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
|
107
9
|
|
108
10
|
## [2.4.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.0...v2.4.1) (2022-11-06)
|
109
11
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.5.0-cx24-
|
3
|
+
"version": "2.5.0-cx24-3175.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,7 +31,6 @@
|
|
31
31
|
"prettier": "1.19.1"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@nuskin/configuration-sdk": "1.0.1",
|
35
34
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
35
|
"@nuskin/ns-util": "3.107.0",
|
37
36
|
"axios": "0.27.2",
|
@@ -98,7 +98,7 @@ function getCachedData(key) {
|
|
98
98
|
* @property {string} checkout_client_secret
|
99
99
|
*
|
100
100
|
* @export
|
101
|
-
* @return {Promise<null|MarketConfig>}
|
101
|
+
* @return {Promise<null|MarketConfig>}
|
102
102
|
*/
|
103
103
|
async function getAEMConfig() {
|
104
104
|
try {
|
@@ -137,7 +137,7 @@ async function getAEMConfig() {
|
|
137
137
|
* @property {string} market_name
|
138
138
|
* @property {string} country_code
|
139
139
|
* @property {string} store_id
|
140
|
-
*
|
140
|
+
*
|
141
141
|
* @typedef EquinoxEnabledMarkets
|
142
142
|
* @property {EquinoxEnabledMarket[]} [dev_markets]
|
143
143
|
* @property {EquinoxEnabledMarket[]} [test_markets]
|
@@ -145,7 +145,7 @@ async function getAEMConfig() {
|
|
145
145
|
* @property {EquinoxEnabledMarket[]} [prod_markets]
|
146
146
|
*
|
147
147
|
* @export
|
148
|
-
* @return {Promise<EquinoxEnabledMarkets>}
|
148
|
+
* @return {Promise<EquinoxEnabledMarkets>}
|
149
149
|
*/
|
150
150
|
async function getEquinoxMarkets() {
|
151
151
|
try {
|
@@ -176,8 +176,8 @@ async function getEquinoxMarkets() {
|
|
176
176
|
}
|
177
177
|
}
|
178
178
|
|
179
|
-
/**getKongUrl gets the URL for Kong in contentstack
|
180
|
-
*
|
179
|
+
/**getKongUrl gets the URL for Kong in contentstack
|
180
|
+
*
|
181
181
|
* @returns {string}
|
182
182
|
*/
|
183
183
|
async function getKongUrl() {
|
package/src/index.js
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
|
8
8
|
const Agelocme = require("./agelocme.js");
|
9
9
|
const Contentstack = require('./contentstack/contentstack');
|
10
|
-
const PriceType = require("./priceType.js");
|
10
|
+
const PriceType = require("./models/priceType.js");
|
11
11
|
const Product = require("./product.js");
|
12
12
|
const ProductContentMapper = require("./productContentMapper.js");
|
13
|
-
const ProductStatus = require("./productStatus.js");
|
13
|
+
const ProductStatus = require("./models/productStatus.js");
|
14
14
|
const ProductStatusMapper = require("./productStatusMapper.js");
|
15
15
|
const ProductUtils = require("./productUtils.js");
|
16
16
|
const ProductData = require("./productData.js");
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const CustomerTypes = {
|
4
|
+
BrandAffiliate: "brandaffiliate",
|
5
|
+
Preferred: "preferred",
|
6
|
+
PreferredCustomer: "preferred customer",
|
7
|
+
Retail: "retail",
|
8
|
+
properties: {
|
9
|
+
BRAND_AFFILIATE: { stringKey: "DIST", code: 10 },
|
10
|
+
RETAIL: { stringKey: "CUST", code: 20 },
|
11
|
+
PREFERRED: { stringKey: "preferred", code: 30 },
|
12
|
+
PREFERRED_CUSTOMER: { stringKey: "PREF", code: 30 }
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
module.exports = CustomerTypes;
|
File without changes
|
@@ -17,6 +17,13 @@ const ProductStatus = {
|
|
17
17
|
STOP_STATUS: { stringKey: "stopStatus", code: 5 },
|
18
18
|
NOT_FOUND: { stringKey: "", code: 0 },
|
19
19
|
NOT_SOLD_SEPERATELY: {stringKey: "notSoldSeperately", code: 4 }
|
20
|
+
},
|
21
|
+
equinoxStatus: {
|
22
|
+
SELLABLE: 'sellable',
|
23
|
+
PREVIEW_PRODUCT: 'preview product',
|
24
|
+
DISCONTINUED: 'discontinued',
|
25
|
+
STOPPED: 'stopped',
|
26
|
+
REPLACEMENT: 'Replacement'
|
20
27
|
}
|
21
28
|
};
|
22
29
|
|
package/src/product.js
CHANGED
@@ -5,8 +5,8 @@ const { isTrue } = require("@nuskin/ns-common-lib");
|
|
5
5
|
const ProductUtils = require("./productUtils.js");
|
6
6
|
|
7
7
|
const Agelocme = require("./agelocme.js");
|
8
|
-
const PriceType = require("./priceType.js");
|
9
|
-
const ProductStatus = require("./productStatus.js");
|
8
|
+
const PriceType = require("./models/priceType.js");
|
9
|
+
const ProductStatus = require("./models/productStatus.js");
|
10
10
|
|
11
11
|
const Product = function(productData) {
|
12
12
|
this.priceMap = {};
|
@@ -75,7 +75,6 @@ const Product = function(productData) {
|
|
75
75
|
//equinox inventory / stock label
|
76
76
|
//@example "IN STOCK"
|
77
77
|
this.inventory = "";
|
78
|
-
this.equinoxProductId = "";
|
79
78
|
|
80
79
|
this.setMarketAttributes = function(productStatus) {
|
81
80
|
if (productStatus.marketAttributes) {
|
@@ -226,7 +225,7 @@ const Product = function(productData) {
|
|
226
225
|
}
|
227
226
|
};
|
228
227
|
|
229
|
-
this.setPriceAndPvFromType = function(_priceType, _activeEvents = null
|
228
|
+
this.setPriceAndPvFromType = function(_priceType, _activeEvents = null) {
|
230
229
|
// WARNING: priceType needs to be handled client-side
|
231
230
|
// const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
|
232
231
|
// ? PriceType.WWHL
|
@@ -235,11 +234,11 @@ const Product = function(productData) {
|
|
235
234
|
const eventPricing = getEventPricing(this, priceType, _activeEvents);
|
236
235
|
|
237
236
|
let changed = false;
|
238
|
-
if (
|
237
|
+
if (
|
239
238
|
!this.price ||
|
240
239
|
priceType !== this.priceType ||
|
241
240
|
this.eventName !== eventPricing.eventName
|
242
|
-
)
|
241
|
+
) {
|
243
242
|
this.setPrice(eventPricing.price || this.getPricing(priceType));
|
244
243
|
this.setCv(eventPricing.cv || this.getCvWithType(priceType));
|
245
244
|
this.setPv(eventPricing.pv || this.getPvWithType(priceType));
|
@@ -248,20 +247,11 @@ const Product = function(productData) {
|
|
248
247
|
changed = true;
|
249
248
|
}
|
250
249
|
|
251
|
-
if (option.isEqPromotion) {
|
252
|
-
//retain product.price as original price
|
253
|
-
this.setCv(this.getCvWithType(priceType));
|
254
|
-
this.setPv(this.getPvWithType(priceType));
|
255
|
-
this.priceType = priceType;
|
256
|
-
changed = true;
|
257
|
-
}
|
258
|
-
|
259
250
|
this.variantSkus().forEach((variantSku) => {
|
260
251
|
if (
|
261
252
|
this.variants[variantSku].setPriceAndPvFromType(
|
262
253
|
priceType,
|
263
|
-
_activeEvents
|
264
|
-
option
|
254
|
+
_activeEvents
|
265
255
|
)
|
266
256
|
) {
|
267
257
|
changed = true;
|
@@ -291,7 +281,7 @@ const Product = function(productData) {
|
|
291
281
|
this.priceMap[type] = price;
|
292
282
|
};
|
293
283
|
|
294
|
-
this.addPricingFromStatus = function(productStatus, priceType
|
284
|
+
this.addPricingFromStatus = function(productStatus, priceType) {
|
295
285
|
let modified = false;
|
296
286
|
|
297
287
|
if (!priceType) {
|
@@ -329,13 +319,13 @@ const Product = function(productData) {
|
|
329
319
|
if(productStatus.childSkus) {
|
330
320
|
this.childSkus = productStatus.childSkus;
|
331
321
|
}
|
332
|
-
this.setPriceAndPvFromType(priceType
|
322
|
+
this.setPriceAndPvFromType(priceType);
|
333
323
|
modified = true;
|
334
324
|
} else {
|
335
325
|
let variant = this.getVariant(productStatusSku);
|
336
326
|
|
337
327
|
if (variant) {
|
338
|
-
if (variant.addPricingFromStatus(productStatus, priceType
|
328
|
+
if (variant.addPricingFromStatus(productStatus, priceType)) {
|
339
329
|
variant.setMarketAttributes(productStatus);
|
340
330
|
updateBaseRanges(this, variant);
|
341
331
|
modified = true;
|
@@ -533,7 +523,6 @@ const Product = function(productData) {
|
|
533
523
|
retData.restrictedMarkets = this.restrictedMarkets;
|
534
524
|
retData.addOns = this.addOns;
|
535
525
|
retData.inventory = this.inventory;
|
536
|
-
retData.equinoxProductId = this.equinoxProductId;
|
537
526
|
|
538
527
|
return retData;
|
539
528
|
};
|
@@ -673,8 +662,6 @@ const Product = function(productData) {
|
|
673
662
|
if (data.agelocme) {
|
674
663
|
this.agelocme = new Agelocme(data.agelocme);
|
675
664
|
}
|
676
|
-
|
677
|
-
this.equinoxProductId = data.equinoxProductId;
|
678
665
|
}
|
679
666
|
};
|
680
667
|
|
package/src/productData.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
const { getConfiguration } = require('@nuskin/configuration-sdk');
|
3
|
-
// import { ConfigService } from '@nuskin/ns-util';
|
4
2
|
const axios = require("axios");
|
5
3
|
const contentstack = require('./contentstack/contentstack');
|
6
4
|
const Product = require("./product");
|
7
|
-
|
5
|
+
const CustomerTypes = require('./models/customerTypes');
|
6
|
+
const ProductStatus = require("./models/productStatus");
|
8
7
|
/** @type {*} */
|
9
8
|
const ProductData = {
|
10
9
|
/**
|
@@ -15,42 +14,37 @@ const ProductData = {
|
|
15
14
|
*/
|
16
15
|
getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
|
17
16
|
const localeMarket = `${locale}_${market}`;
|
18
|
-
|
17
|
+
|
19
18
|
if (isEquinoxEnabled) {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
clientId: '735b1eb810304bba966af0891ab54053'
|
25
|
-
})).Equinox_Markets;
|
26
|
-
if (config.country_code != '') {
|
27
|
-
return await this.getProductFromEquinox(skus, localeMarket, config);
|
19
|
+
const marketConfig = await contentstack.isMarketEnabled(market);
|
20
|
+
|
21
|
+
if (marketConfig !== null) {
|
22
|
+
return await this.getProductFromEquinox(skus, localeMarket, marketConfig.store_id);
|
28
23
|
}
|
29
24
|
}
|
30
|
-
|
25
|
+
|
31
26
|
return await this.getProductFromLegacy(skus, localeMarket);
|
32
27
|
},
|
33
|
-
|
34
|
-
getProductFromEquinox: async function (skus, locale,
|
35
|
-
|
36
|
-
const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
|
28
|
+
|
29
|
+
getProductFromEquinox: async function (skus, locale, storeID) {
|
30
|
+
const filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' + skus.toString() + '"}]}';
|
37
31
|
axios.defaults.withCredentials = true;
|
38
32
|
|
39
|
-
const url =
|
33
|
+
const url = await contentstack.getKongUrl() + `/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:
|
40
|
+
storeId: storeID
|
47
41
|
},
|
48
42
|
headers: this.getEquinoxRequestHeaders(),
|
49
43
|
responseType: 'json'
|
50
44
|
});
|
51
45
|
|
52
46
|
if (response.data.product) {
|
53
|
-
return this.eqProductMapper(response.data.product
|
47
|
+
return this.eqProductMapper(response.data.product);
|
54
48
|
}
|
55
49
|
|
56
50
|
return {
|
@@ -98,11 +92,11 @@ const ProductData = {
|
|
98
92
|
|
99
93
|
/**
|
100
94
|
* Map product variant
|
101
|
-
* @todo remove unnecessary fields
|
95
|
+
* @todo remove unnecessary fields
|
102
96
|
* @param {*} eqVariant
|
103
97
|
* @returns Array<Product>
|
104
98
|
*/
|
105
|
-
|
99
|
+
j : function (eqVariant) {
|
106
100
|
|
107
101
|
let imageURL = eqVariant.properties.imageURL;
|
108
102
|
const regex = /\d+.\d+/
|
@@ -114,10 +108,6 @@ const ProductData = {
|
|
114
108
|
thumbnailImage = imageURL.replace(regex,'40.40')
|
115
109
|
}
|
116
110
|
|
117
|
-
const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(eqVariant);
|
118
|
-
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
119
|
-
const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
|
120
|
-
|
121
111
|
return {
|
122
112
|
"sku": eqVariant.identifier,
|
123
113
|
"globalProductID": eqVariant.identifier,
|
@@ -156,14 +146,14 @@ const ProductData = {
|
|
156
146
|
"cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
|
157
147
|
"pv":eqVariant.priceFacets.PV,
|
158
148
|
"priceType": "WRTL",
|
159
|
-
"price":
|
149
|
+
"price": eqVariant.priceFacets["Regular Price"],
|
160
150
|
"priceMap": {
|
161
|
-
"WRTL":
|
151
|
+
"WRTL": eqVariant.priceFacets["Regular Price"],
|
162
152
|
"WADW-WRTL": eqVariant.priceFacets["Regular Price"],
|
163
|
-
"WADR":
|
153
|
+
"WADR": 9999.01,
|
164
154
|
"RTL": eqVariant.priceFacets["Regular Price"],
|
165
155
|
"WWHL": eqVariant.priceFacets["Wholesale Price"],
|
166
|
-
"WADW":
|
156
|
+
"WADW": 9998.01,
|
167
157
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
168
158
|
},
|
169
159
|
"cvMap": {
|
@@ -176,7 +166,19 @@ const ProductData = {
|
|
176
166
|
"WADW": eqVariant.priceFacets.PV,
|
177
167
|
"WHL": eqVariant.priceFacets.PV
|
178
168
|
},
|
179
|
-
"orderTypes":
|
169
|
+
"orderTypes": {
|
170
|
+
"adr": true,
|
171
|
+
"order": true,
|
172
|
+
"zpfc": false,
|
173
|
+
"zadp": true,
|
174
|
+
"ars": true,
|
175
|
+
"kiosk": true,
|
176
|
+
"mobile": true,
|
177
|
+
"preferred customer": true,
|
178
|
+
"retail": true,
|
179
|
+
"web": true,
|
180
|
+
"web display": true
|
181
|
+
},
|
180
182
|
"division": eqVariant.properties.division,
|
181
183
|
"backOrderDate": null,
|
182
184
|
"locallyProduced": false,
|
@@ -187,65 +189,29 @@ const ProductData = {
|
|
187
189
|
"shade": "",
|
188
190
|
"status": this.switchStatusFromEquinox(eqVariant.properties.status),
|
189
191
|
"variantType": "Other",
|
190
|
-
"variantDropdownLabel": eqVariant.properties.
|
192
|
+
"variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
|
191
193
|
"variantDropdownPlaceholder": "Select Type",
|
192
|
-
"variantsLabel": eqVariant.properties.
|
194
|
+
"variantsLabel": eqVariant.properties.variantSelectLabel || "",
|
193
195
|
"groupOffer": false,
|
194
196
|
"personalOffer": false,
|
195
|
-
"savedEventName":
|
196
|
-
"salesLabel":
|
197
|
-
"eventName":
|
197
|
+
"savedEventName": null,
|
198
|
+
"salesLabel": "",
|
199
|
+
"eventName": null,
|
198
200
|
"sizeWeight": '',
|
199
201
|
"nettoWeight": "",
|
200
202
|
"searchScore": 0,
|
201
|
-
"isExclusive": false,
|
203
|
+
"isExclusive": eqVariant.properties.isExclusive || false,
|
202
204
|
"marketAttributes": {
|
203
205
|
"discount": true,
|
204
206
|
"redeem": true,
|
205
207
|
"earn": true
|
206
208
|
},
|
207
209
|
"restrictedMarkets": [],
|
208
|
-
"addOns": []
|
209
|
-
"equinoxProductId": eqVariant.identifier
|
210
|
+
"addOns": []
|
210
211
|
};
|
211
212
|
},
|
212
213
|
|
213
|
-
|
214
|
-
* Get EQ product promotions
|
215
|
-
* @param {*} product
|
216
|
-
* @returns {obj} promotion
|
217
|
-
*/
|
218
|
-
getEqProductPromotions(product) {
|
219
|
-
|
220
|
-
if (!Array.isArray(product.promotion)) {
|
221
|
-
return {
|
222
|
-
eventLabels: "",
|
223
|
-
computedPrice : 0,
|
224
|
-
defaultProductPrice: product.priceFacets ? product.priceFacets["Regular Price"] : 0,
|
225
|
-
eventName: null
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
|
230
|
-
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount ? product.totalValue.priceAfterDiscount : 0;
|
231
|
-
let eventName = "";
|
232
|
-
const eventLabels = [];
|
233
|
-
|
234
|
-
product.promotion.map(promotion => {
|
235
|
-
eventName = promotion.offerId;
|
236
|
-
eventLabels.push(promotion.message);
|
237
|
-
return promotion;
|
238
|
-
});
|
239
|
-
|
240
|
-
return {
|
241
|
-
eventLabels: eventLabels.join(','),
|
242
|
-
defaultProductPrice,
|
243
|
-
computedPrice,
|
244
|
-
eventName
|
245
|
-
}
|
246
|
-
},
|
247
|
-
|
248
|
-
eqProductMapper: function (productDataResponse, skus) {
|
214
|
+
eqProductMapper: function (productDataResponse) {
|
249
215
|
let prod = [];
|
250
216
|
let count = 0;
|
251
217
|
let variants = {};
|
@@ -262,17 +228,12 @@ const ProductData = {
|
|
262
228
|
}
|
263
229
|
|
264
230
|
if (data.sku && data.sku.length > 1) {
|
265
|
-
|
266
|
-
data.sku.filter(v => v.identifier.substring(2, 4) !== "55").map(variant => {
|
231
|
+
data.sku.map(variant => {
|
267
232
|
variants[variant.identifier] = this.eqProductVariantMapper(variant);
|
268
233
|
return variant;
|
269
234
|
});
|
270
235
|
}
|
271
236
|
|
272
|
-
const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(data.sku[count]);
|
273
|
-
const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
|
274
|
-
const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
|
275
|
-
|
276
237
|
prod = {
|
277
238
|
"sku": data.sku[count].identifier,
|
278
239
|
"globalProductID": data.identifier,
|
@@ -311,13 +272,13 @@ const ProductData = {
|
|
311
272
|
"cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
|
312
273
|
"pv": data.sku[count].priceFacets.PV,
|
313
274
|
"priceType": "WRTL",
|
314
|
-
"price":
|
275
|
+
"price": data.sku[count].priceFacets["Regular Price"],
|
315
276
|
"priceMap": {
|
316
|
-
"WRTL":
|
277
|
+
"WRTL": data.sku[count].priceFacets["Regular Price"],
|
317
278
|
"WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
|
318
|
-
"WADR":
|
279
|
+
"WADR": 9999.01,
|
319
280
|
"RTL": data.sku[count].priceFacets["Regular Price"],
|
320
|
-
"WADW":
|
281
|
+
"WADW": 9998.01,
|
321
282
|
"WHL": data.sku[count].priceFacets["Wholesale Price"],
|
322
283
|
"WWHL": data.sku[count].priceFacets["Wholesale Price"]
|
323
284
|
},
|
@@ -331,7 +292,19 @@ const ProductData = {
|
|
331
292
|
"WADW": data.sku[count].priceFacets.PV,
|
332
293
|
"WHL": data.sku[count].priceFacets.PV
|
333
294
|
},
|
334
|
-
"orderTypes":
|
295
|
+
"orderTypes": {
|
296
|
+
"adr": true,
|
297
|
+
"order": true,
|
298
|
+
"zpfc": false,
|
299
|
+
"zadp": true,
|
300
|
+
"ars": true,
|
301
|
+
"kiosk": true,
|
302
|
+
"mobile": true,
|
303
|
+
"preferred customer": true,
|
304
|
+
"retail": true,
|
305
|
+
"web": true,
|
306
|
+
"web display": true
|
307
|
+
},
|
335
308
|
"childSkus": [],
|
336
309
|
"custTypes": this.switchCustType(data.properties.customerTypes),
|
337
310
|
"division": data.properties.division,
|
@@ -349,14 +322,14 @@ const ProductData = {
|
|
349
322
|
"variantsLabel": data.sku[count].properties.variantLabel || "",
|
350
323
|
"groupOffer": false,
|
351
324
|
"personalOffer": false,
|
352
|
-
"savedEventName":
|
353
|
-
"salesLabel":
|
354
|
-
"eventName":
|
325
|
+
"savedEventName": null,
|
326
|
+
"salesLabel": "",
|
327
|
+
"eventName": null,
|
355
328
|
"sizeWeight": '',
|
356
329
|
"nettoWeight": "",
|
357
330
|
"variants": variants,
|
358
331
|
"searchScore": 0,
|
359
|
-
"isExclusive": data.sku[count].properties.isExclusive,
|
332
|
+
"isExclusive": data.sku[count].properties.isExclusive || false,
|
360
333
|
"marketAttributes": {
|
361
334
|
"discount": true,
|
362
335
|
"redeem": true,
|
@@ -364,15 +337,15 @@ const ProductData = {
|
|
364
337
|
},
|
365
338
|
"restrictedMarkets": [],
|
366
339
|
"addOns": [],
|
367
|
-
"inventory": data.sku[count].inventory || ""
|
368
|
-
|
340
|
+
"inventory": data.sku[count].inventory || "" //inventory label
|
341
|
+
|
369
342
|
};
|
370
343
|
let newProduct = new Product(prod);
|
371
344
|
return newProduct
|
372
|
-
})
|
345
|
+
})
|
373
346
|
|
374
347
|
let data = {
|
375
|
-
products:
|
348
|
+
products: prodArr,
|
376
349
|
count: productDataResponse.length
|
377
350
|
};
|
378
351
|
return {
|
@@ -385,27 +358,29 @@ const ProductData = {
|
|
385
358
|
},
|
386
359
|
|
387
360
|
switchStatusFromEquinox: function (status) {
|
361
|
+
const { equinoxStatus } = ProductStatus;
|
388
362
|
let newStatus = '';
|
389
|
-
switch (status) {
|
390
|
-
case
|
391
|
-
newStatus =
|
363
|
+
switch (status.toLowerCase()) {
|
364
|
+
case equinoxStatus.SELLABLE:
|
365
|
+
newStatus = ProductStatus.ReleasedForSale;
|
392
366
|
break;
|
393
|
-
case
|
394
|
-
newStatus =
|
367
|
+
case equinoxStatus.PREVIEW_PRODUCT:
|
368
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
395
369
|
break;
|
396
|
-
case
|
397
|
-
newStatus =
|
370
|
+
case equinoxStatus.DISCONTINUED:
|
371
|
+
newStatus = ProductStatus.Discontinued;
|
398
372
|
break;
|
399
|
-
case
|
400
|
-
newStatus =
|
373
|
+
case equinoxStatus.STOPPED:
|
374
|
+
newStatus = ProductStatus.Discontinued;
|
401
375
|
break;
|
402
|
-
case
|
403
|
-
newStatus =
|
376
|
+
case equinoxStatus.REPLACEMENT:
|
377
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
404
378
|
break;
|
405
379
|
default:
|
406
|
-
newStatus =
|
380
|
+
newStatus = ProductStatus.NotReleasedForSale;
|
407
381
|
break;
|
408
382
|
}
|
383
|
+
|
409
384
|
return newStatus;
|
410
385
|
},
|
411
386
|
|
@@ -414,92 +389,33 @@ const ProductData = {
|
|
414
389
|
* @param {*} custType
|
415
390
|
*
|
416
391
|
*/
|
417
|
-
switchCustType: function (custType) {
|
418
|
-
let newCustType = [];
|
419
|
-
if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
|
420
|
-
newCustType.push(10)
|
421
|
-
if (custType.includes('Retail Customer'))
|
422
|
-
newCustType.push(20)
|
423
|
-
if (custType.includes('Preferred Customer/Member'))
|
424
|
-
newCustType.push(30)
|
425
|
-
return newCustType.toString()
|
426
|
-
},
|
427
392
|
|
428
393
|
/**
|
429
|
-
*
|
430
|
-
* @param {
|
431
|
-
* @
|
394
|
+
* map customer types from string to code
|
395
|
+
* @param {*} eqCustomerTypes
|
396
|
+
* @returns
|
432
397
|
*/
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
if(!skus || !products || products.length === 1) {
|
437
|
-
return products
|
398
|
+
switchCustType: function (eqCustomerTypes) {
|
399
|
+
if (!eqCustomerTypes) {
|
400
|
+
return "";
|
438
401
|
}
|
439
402
|
|
440
|
-
const
|
441
|
-
return skus.indexOf(a.sku) - skus.indexOf(b.sku);
|
442
|
-
});
|
443
|
-
|
444
|
-
return sortedProducts
|
403
|
+
const custTypes = eqCustomerTypes.split(',').map(customerType => customerType.toLowerCase());
|
445
404
|
|
446
|
-
|
405
|
+
let newCustType = [];
|
406
|
+
if (custTypes.includes(CustomerTypes.BrandAffiliate)) {
|
407
|
+
newCustType.push(CustomerTypes.properties.BRAND_AFFILIATE.code);
|
408
|
+
}
|
447
409
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
*
|
452
|
-
* This function is use to convert arsPhone,web,kiosk,mobile,subscription
|
453
|
-
* to orderType object
|
454
|
-
* "adr”
|
455
|
-
"order"
|
456
|
-
"zpfc"
|
457
|
-
"zadp"
|
458
|
-
"ars"
|
459
|
-
"kiosk"
|
460
|
-
"mobile"
|
461
|
-
"preferred customer"
|
462
|
-
"retail"
|
463
|
-
"web"
|
464
|
-
"web display"
|
465
|
-
*/
|
466
|
-
_setOrderType: function (properties) {
|
467
|
-
let orderTypeArr = {
|
468
|
-
"adr": false,
|
469
|
-
"order": false,
|
470
|
-
"zpfc": false,
|
471
|
-
"zadp": false,
|
472
|
-
"ars": false,
|
473
|
-
"kiosk": false,
|
474
|
-
"mobile": false,
|
475
|
-
"preferred customer": false,
|
476
|
-
"retail": false,
|
477
|
-
"web": false,
|
478
|
-
"web display": false
|
479
|
-
};
|
480
|
-
let availableChannelsArr = properties.availableChannels.split(',')
|
481
|
-
|
482
|
-
availableChannelsArr.forEach(channel => {
|
483
|
-
if (channel == 'arsPhone')
|
484
|
-
orderTypeArr.ars = true
|
485
|
-
if (channel == 'web') {
|
486
|
-
orderTypeArr.order = true
|
487
|
-
orderTypeArr.web = true
|
488
|
-
}
|
489
|
-
if (channel == 'kiosk')
|
490
|
-
orderTypeArr.kiosk = true
|
491
|
-
if (channel == 'mobile')
|
492
|
-
orderTypeArr.mobile = true
|
493
|
-
if (channel == 'subscription')
|
494
|
-
orderTypeArr.adr = true
|
410
|
+
if (custTypes.includes(CustomerTypes.Retail)) {
|
411
|
+
newCustType.push(CustomerTypes.properties.RETAIL.code);
|
412
|
+
}
|
495
413
|
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
if (properties.prefferredCustomer)
|
500
|
-
orderTypeArr['preferred customer'] = true
|
414
|
+
if (custTypes.includes(CustomerTypes.Preferred) || custTypes.includes(CustomerTypes.PreferredCustomer)) {
|
415
|
+
newCustType.push(CustomerTypes.properties.PREFERRED.code);
|
416
|
+
}
|
501
417
|
|
502
|
-
return
|
418
|
+
return newCustType.toString()
|
503
419
|
}
|
504
420
|
}
|
505
421
|
|