@nuskin/ns-product-lib 2.6.2-cx24-337703.1 → 2.7.0-cx24-337701.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +93 -13
- package/package.json +2 -2
- package/src/equinox-helpers/index.js +4 -43
- package/src/product.js +63 -62
- package/src/productData.js +187 -139
- package/src/equinox-helpers/childSKU.js +0 -31
package/CHANGELOG.md
CHANGED
@@ -1,45 +1,125 @@
|
|
1
|
-
|
1
|
+
# [2.7.0-cx24-337701.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.15...v2.7.0-cx24-337701.1) (2023-03-22)
|
2
2
|
|
3
3
|
|
4
4
|
### Fix
|
5
5
|
|
6
|
-
*
|
6
|
+
* Lint Errors after merge ([86f07a8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/86f07a8b27e5f772d364ec40c1c0014f534f0312))
|
7
7
|
|
8
|
-
|
8
|
+
### Update
|
9
|
+
|
10
|
+
* Merge CX24-3563 changes to CX24-337701 ([9daed9a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9daed9a062d42b0de11fcc0a56d65f37cfd6ec17))
|
11
|
+
|
12
|
+
## [2.6.1-cx24-337701.15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.14...v2.6.1-cx24-337701.15) (2023-03-21)
|
13
|
+
|
14
|
+
|
15
|
+
### Fix
|
16
|
+
|
17
|
+
* Show dropdown for variants ([8edac62](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8edac62b88fe058fe232e9c8c9da557351c10338))
|
18
|
+
|
19
|
+
## [2.6.1-cx24-337701.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.13...v2.6.1-cx24-337701.14) (2023-03-21)
|
20
|
+
|
21
|
+
|
22
|
+
### Fix
|
23
|
+
|
24
|
+
* Show dropdown for variants ([cf5e6a6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cf5e6a600008465d32b0d77ed46f8518802f4295))
|
25
|
+
* Show dropdown for variants ([8c29f14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8c29f14e20e9f674c8942274607abd1dd4f82964))
|
26
|
+
|
27
|
+
## [2.6.1-cx24-337701.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.12...v2.6.1-cx24-337701.13) (2023-03-20)
|
28
|
+
|
29
|
+
|
30
|
+
### Fix
|
31
|
+
|
32
|
+
* multi variant drop down ([4c61780](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4c617806a2934b1aca7b5280810107cf0356b29b))
|
33
|
+
|
34
|
+
## [2.6.1-cx24-337701.12](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.11...v2.6.1-cx24-337701.12) (2023-03-20)
|
35
|
+
|
36
|
+
|
37
|
+
### Fix
|
38
|
+
|
39
|
+
* The variant drop down label ([235a252](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/235a252cd59a94704400743e51d043d2ca2b9074))
|
40
|
+
* The variant drop down label ([e43614e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e43614ece7f3bb7d8c0d12743ab02b90427cbbb9))
|
41
|
+
|
42
|
+
## [2.6.1-cx24-337701.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.10...v2.6.1-cx24-337701.11) (2023-03-20)
|
43
|
+
|
44
|
+
|
45
|
+
### Fix
|
46
|
+
|
47
|
+
* The variant drop down label ([de58922](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/de589221aee054cbfb765117a44cd2fca4575468))
|
48
|
+
|
49
|
+
## [2.6.1-cx24-337701.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.9...v2.6.1-cx24-337701.10) (2023-03-20)
|
50
|
+
|
51
|
+
|
52
|
+
### Fix
|
53
|
+
|
54
|
+
* The variant drop down label ([a93900f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a93900f43e880b52383ea22df8d496f97be21535))
|
55
|
+
* The variant drop down label ([20bc315](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/20bc315ba14213d5e18101c9016d3d07da14843a))
|
56
|
+
* The variant drop down label ([8bb8f1c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8bb8f1c11626645d2cd4ca1a4db29f75b99dff7b))
|
57
|
+
|
58
|
+
## [2.6.1-cx24-337701.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.8...v2.6.1-cx24-337701.9) (2023-03-20)
|
59
|
+
|
60
|
+
|
61
|
+
### Fix
|
62
|
+
|
63
|
+
* The variant drop down label ([a35121b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a35121b96fb7d0e62119e4bebea9d513cd2e8814))
|
64
|
+
|
65
|
+
## [2.6.1-cx24-337701.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.7...v2.6.1-cx24-337701.8) (2023-03-20)
|
66
|
+
|
67
|
+
|
68
|
+
### Fix
|
69
|
+
|
70
|
+
* The variant drop down label ([226e964](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/226e96475b26ef4eda94ac63028285f27c9a81ba))
|
71
|
+
|
72
|
+
## [2.6.1-cx24-337701.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.6...v2.6.1-cx24-337701.7) (2023-03-20)
|
73
|
+
|
74
|
+
|
75
|
+
### Fix
|
76
|
+
|
77
|
+
* The variant drop down label ([0406e11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0406e11e1fa9aa71313b80fae06c9e8bd8d406d8))
|
78
|
+
|
79
|
+
## [2.6.1-cx24-337701.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.5...v2.6.1-cx24-337701.6) (2023-03-20)
|
80
|
+
|
81
|
+
|
82
|
+
### Fix
|
83
|
+
|
84
|
+
* The variant drop down label ([738b2a4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/738b2a41ab2fc2900529234b3fa860f9102fc36d))
|
85
|
+
* The variant drop down label ([58af789](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/58af78921e2eff83beffd6b5665aff6d60bbb21b))
|
86
|
+
|
87
|
+
## [2.6.1-cx24-337701.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.4...v2.6.1-cx24-337701.5) (2023-03-19)
|
9
88
|
|
10
89
|
|
11
90
|
### Fix
|
12
91
|
|
13
|
-
*
|
92
|
+
* The variant drop down label ([2e175c1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2e175c12f24b789f913e64fff5e26b3257ccd087))
|
14
93
|
|
15
|
-
## [2.6.1-cx24-
|
94
|
+
## [2.6.1-cx24-337701.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.3...v2.6.1-cx24-337701.4) (2023-03-19)
|
16
95
|
|
17
96
|
|
18
97
|
### Fix
|
19
98
|
|
20
|
-
* The variant drop down label ([
|
99
|
+
* The variant drop down label ([71faac8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/71faac8db3a4a03d1addcda266b21616c5b0f044))
|
21
100
|
|
22
|
-
## [2.6.1-cx24-
|
101
|
+
## [2.6.1-cx24-337701.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.2...v2.6.1-cx24-337701.3) (2023-03-19)
|
23
102
|
|
24
103
|
|
25
104
|
### Fix
|
26
105
|
|
27
|
-
*
|
106
|
+
* The variant drop down label ([707ddb3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/707ddb37391363059c86460e5da575b78409e250))
|
28
107
|
|
29
|
-
## [2.6.1-cx24-
|
108
|
+
## [2.6.1-cx24-337701.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1-cx24-337701.1...v2.6.1-cx24-337701.2) (2023-03-19)
|
30
109
|
|
31
110
|
|
32
111
|
### Fix
|
33
112
|
|
34
|
-
*
|
113
|
+
* The variant drop down label ([973f145](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/973f1455a91127d575a8fc7d26e7e78d05f1f0a4))
|
35
114
|
|
36
|
-
## [2.6.1-cx24-
|
115
|
+
## [2.6.1-cx24-337701.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0...v2.6.1-cx24-337701.1) (2023-03-19)
|
37
116
|
|
38
117
|
|
39
118
|
### Fix
|
40
119
|
|
41
|
-
*
|
42
|
-
*
|
120
|
+
* The variant drop down label ([bd60148](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bd60148d1a50e895d36139932740fe4ee7f9f50a))
|
121
|
+
* The variant drop down label ([749b476](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/749b47605995405886460b29f20411a21e45fb68))
|
122
|
+
* The variant drop down label ([bc555ab](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bc555abec97bca95fc0ba18a0eb4f0a0c9cd537a))
|
43
123
|
|
44
124
|
# [2.6.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.2...v2.6.0) (2023-03-13)
|
45
125
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.7.0-cx24-337701.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": {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"dependencies": {
|
34
34
|
"@nuskin/configuration-sdk": "2.2.3",
|
35
35
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
|
-
"@nuskin/ns-util": "4.2.
|
36
|
+
"@nuskin/ns-util": "4.2.5",
|
37
37
|
"axios": "0.27.2",
|
38
38
|
"qs": "6.11.0"
|
39
39
|
},
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/**
|
2
|
-
* @description This model represents the mapped values of a product
|
3
2
|
* @typedef Product
|
4
3
|
* @type {object}
|
5
|
-
* @property {
|
4
|
+
* @property {ChildSku[]} childSkus
|
6
5
|
* @property {Inventory} [inventoryProperties]
|
7
|
-
*
|
8
|
-
* @typedef
|
6
|
+
*
|
7
|
+
* @typedef ChildSku
|
9
8
|
* @type {object}
|
10
9
|
* @property {string} productId
|
11
10
|
* @property {string} skuId
|
@@ -13,52 +12,14 @@
|
|
13
12
|
* @property {number} skuQuantity
|
14
13
|
* @property {string} availableChannels
|
15
14
|
* @property {Inventory} [inventory]
|
16
|
-
*
|
17
|
-
* ---
|
18
|
-
*
|
19
|
-
* @description This model represents a product within an Equinox response.
|
20
|
-
* @typedef EquinoxProduct
|
21
|
-
* @type {object}
|
22
|
-
* @property {string} identifier
|
23
|
-
* @property {EquinoxProductSKU[]} sku
|
24
|
-
* @property {"kit"|"bundle"} [type]
|
25
|
-
*
|
26
|
-
* @typedef EquinoxProductSKU
|
27
|
-
* @type {object}
|
28
|
-
* @property {boolean} default
|
29
|
-
* For multi-variant products, this indicates that this is the searched SKU
|
30
|
-
* when using catalogs/search endpoint.
|
31
|
-
* @property {string} identifier
|
32
|
-
* @property {Inventory} inventoryProperties
|
33
|
-
* @property {EquinoxProductProperties} properties
|
34
|
-
*
|
35
|
-
* @typedef EquinoxProductProperties
|
36
|
-
* @type {object}
|
37
|
-
* @property {string} availableChannels
|
38
|
-
*
|
39
|
-
* ---
|
40
|
-
*
|
41
|
-
* Types common to Product model and Equinox Product model
|
42
15
|
*
|
43
16
|
* @typedef Inventory
|
44
17
|
* @type {object}
|
45
18
|
* @property {number} atpQty
|
46
19
|
* @property {boolean} backOrdered
|
47
|
-
*
|
48
|
-
* ---
|
49
|
-
*
|
50
|
-
* Standalone types. These are types not related to Product
|
51
|
-
* and Equinox Product models.
|
52
|
-
*
|
53
|
-
* @typedef KitSKUQuantity
|
54
|
-
* @type {object}
|
55
|
-
* @property {string} sku
|
56
|
-
* @property {number} qty
|
57
20
|
*/
|
58
21
|
const availableQuantity = require('./availableQuantity');
|
59
|
-
const childSKU = require('./childSKU');
|
60
22
|
|
61
23
|
module.exports = {
|
62
|
-
mapAvailableQuantity: availableQuantity
|
63
|
-
mapChildSKU: childSKU
|
24
|
+
mapAvailableQuantity: availableQuantity
|
64
25
|
};
|
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 = {};
|
@@ -76,14 +76,15 @@ const Product = function(productData) {
|
|
76
76
|
//@example "IN STOCK"
|
77
77
|
this.inventory = "";
|
78
78
|
this.equinoxProductId = "";
|
79
|
+
this.variantDefault = false;
|
79
80
|
|
80
|
-
this.setMarketAttributes = function(productStatus) {
|
81
|
+
this.setMarketAttributes = function (productStatus) {
|
81
82
|
if (productStatus.marketAttributes) {
|
82
83
|
this.marketAttributes = productStatus.marketAttributes;
|
83
84
|
}
|
84
85
|
};
|
85
86
|
|
86
|
-
this.getAgelocmeKeyPart = function() {
|
87
|
+
this.getAgelocmeKeyPart = function () {
|
87
88
|
let keyPart = null;
|
88
89
|
if (this.agelocme) {
|
89
90
|
keyPart =
|
@@ -97,27 +98,27 @@ const Product = function(productData) {
|
|
97
98
|
return keyPart;
|
98
99
|
};
|
99
100
|
|
100
|
-
this.getHighlightedSku = function() {
|
101
|
+
this.getHighlightedSku = function () {
|
101
102
|
let rv = this.sku;
|
102
103
|
if (this.highlightedSku) rv = this.highlightedSku;
|
103
104
|
return rv;
|
104
105
|
};
|
105
106
|
|
106
|
-
this.getProductSearchTitle = function() {
|
107
|
+
this.getProductSearchTitle = function () {
|
107
108
|
if (this.agelocme && this.agelocme.label) {
|
108
109
|
return this.agelocme.label;
|
109
110
|
}
|
110
111
|
return this.title;
|
111
112
|
};
|
112
113
|
|
113
|
-
this.getProductSearchSku = function() {
|
114
|
+
this.getProductSearchSku = function () {
|
114
115
|
if (this.agelocme && this.agelocme.code) {
|
115
116
|
return this.agelocme.code;
|
116
117
|
}
|
117
118
|
return this.getHighlightedSku();
|
118
119
|
};
|
119
120
|
|
120
|
-
this.getDescription = function() {
|
121
|
+
this.getDescription = function () {
|
121
122
|
let description = this.longDescr;
|
122
123
|
if (!description || description.length === 0) {
|
123
124
|
return this.shortDescr;
|
@@ -125,7 +126,7 @@ const Product = function(productData) {
|
|
125
126
|
return description;
|
126
127
|
};
|
127
128
|
|
128
|
-
this.setFullImage = function(fullImage) {
|
129
|
+
this.setFullImage = function (fullImage) {
|
129
130
|
if (fullImage) {
|
130
131
|
this.fullImage = fullImage.replace("http:", "https:");
|
131
132
|
} else {
|
@@ -133,19 +134,19 @@ const Product = function(productData) {
|
|
133
134
|
}
|
134
135
|
};
|
135
136
|
|
136
|
-
this.getFullImage = function() {
|
137
|
+
this.getFullImage = function () {
|
137
138
|
return this.fullImage ? this.fullImage.replace("http:", "https:") : "";
|
138
139
|
};
|
139
140
|
|
140
|
-
this.setProductCarouselImages = function(productCarouselImages) {
|
141
|
+
this.setProductCarouselImages = function (productCarouselImages) {
|
141
142
|
this.productCarouselImages = productCarouselImages;
|
142
143
|
};
|
143
144
|
|
144
|
-
this.getProductCarouselImages = function() {
|
145
|
+
this.getProductCarouselImages = function () {
|
145
146
|
return this.productCarouselImages;
|
146
147
|
};
|
147
148
|
|
148
|
-
this.setImageAltText = function(altText) {
|
149
|
+
this.setImageAltText = function (altText) {
|
149
150
|
if (altText) {
|
150
151
|
this.imageAltText = altText;
|
151
152
|
} else {
|
@@ -153,11 +154,11 @@ const Product = function(productData) {
|
|
153
154
|
}
|
154
155
|
};
|
155
156
|
|
156
|
-
this.getImageAltText = function() {
|
157
|
+
this.getImageAltText = function () {
|
157
158
|
return this.imageAltText || this.title;
|
158
159
|
};
|
159
160
|
|
160
|
-
this.setThumbnail = function(thumbnail) {
|
161
|
+
this.setThumbnail = function (thumbnail) {
|
161
162
|
if (thumbnail) {
|
162
163
|
this.thumbnail = thumbnail.replace("http:", "https:");
|
163
164
|
} else {
|
@@ -165,7 +166,7 @@ const Product = function(productData) {
|
|
165
166
|
}
|
166
167
|
};
|
167
168
|
|
168
|
-
this.setThumbnailFromSku = function(sku) {
|
169
|
+
this.setThumbnailFromSku = function (sku) {
|
169
170
|
// WARNING: Base URL will need to be handled in the client (call setBaseUrl)
|
170
171
|
// eslint-disable-next-line max-len
|
171
172
|
// this.thumbnail = `${RunConfigService.getBaseUrl()}/content/products/${ProductUtils.getTokenizedSku(sku)}/jcr:content/fullImage.img.100.100.png`;
|
@@ -175,43 +176,43 @@ const Product = function(productData) {
|
|
175
176
|
)}/jcr:content/fullImage.img.100.100.png`;
|
176
177
|
};
|
177
178
|
|
178
|
-
this.getThumbnail = function() {
|
179
|
+
this.getThumbnail = function () {
|
179
180
|
return this.thumbnail ? this.thumbnail.replace("http:", "https:") : "";
|
180
181
|
};
|
181
182
|
|
182
|
-
this.hasAvailableQuantity = function(qty = 1) {
|
183
|
+
this.hasAvailableQuantity = function (qty = 1) {
|
183
184
|
return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
|
184
185
|
};
|
185
186
|
|
186
|
-
this.setPoints = function(points) {
|
187
|
+
this.setPoints = function (points) {
|
187
188
|
this.points = ensureFloatVal(points) || "";
|
188
189
|
};
|
189
190
|
|
190
|
-
this.getPointsFixed = function() {
|
191
|
+
this.getPointsFixed = function () {
|
191
192
|
return parseFloat(this.points).toFixed(2);
|
192
193
|
};
|
193
194
|
|
194
|
-
this.setCv = function(cv) {
|
195
|
+
this.setCv = function (cv) {
|
195
196
|
this.cv = ensureFloatVal(cv) || "";
|
196
197
|
};
|
197
198
|
|
198
|
-
this.getCvFixed = function() {
|
199
|
+
this.getCvFixed = function () {
|
199
200
|
return parseFloat(this.cv).toFixed(2);
|
200
201
|
};
|
201
202
|
|
202
|
-
this.setPv = function(pv) {
|
203
|
+
this.setPv = function (pv) {
|
203
204
|
this.pv = ensureFloatVal(pv) || "";
|
204
205
|
};
|
205
206
|
|
206
|
-
this.getPvFixed = function() {
|
207
|
+
this.getPvFixed = function () {
|
207
208
|
return parseFloat(this.pv || 0).toFixed(2);
|
208
209
|
};
|
209
210
|
|
210
|
-
this.setPrice = function(price) {
|
211
|
+
this.setPrice = function (price) {
|
211
212
|
this.price = ensureFloatVal(price, true);
|
212
213
|
};
|
213
214
|
|
214
|
-
this.setFormattedPrice = function(formattedPrice) {
|
215
|
+
this.setFormattedPrice = function (formattedPrice) {
|
215
216
|
this.formattedPrice = formattedPrice;
|
216
217
|
};
|
217
218
|
|
@@ -220,13 +221,13 @@ const Product = function(productData) {
|
|
220
221
|
* added to the cart the event pricing needs to be remembered if toggling between
|
221
222
|
* pricetypes with event pricing and pricetype without event pricing
|
222
223
|
*/
|
223
|
-
this.lockEventName = function() {
|
224
|
+
this.lockEventName = function () {
|
224
225
|
if (!this.savedEventName && this.eventName) {
|
225
226
|
this.savedEventName = this.eventName;
|
226
227
|
}
|
227
228
|
};
|
228
229
|
|
229
|
-
this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
|
230
|
+
this.setPriceAndPvFromType = function (_priceType, _activeEvents = null, option = {}) {
|
230
231
|
// WARNING: priceType needs to be handled client-side
|
231
232
|
// const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
|
232
233
|
// ? PriceType.WWHL
|
@@ -271,11 +272,11 @@ const Product = function(productData) {
|
|
271
272
|
return changed;
|
272
273
|
};
|
273
274
|
|
274
|
-
this.getPrice = function() {
|
275
|
+
this.getPrice = function () {
|
275
276
|
return this.price ? this.price : 0;
|
276
277
|
};
|
277
278
|
|
278
|
-
this.getPriceFixed = function() {
|
279
|
+
this.getPriceFixed = function () {
|
279
280
|
if (typeof this.price === "number") {
|
280
281
|
return parseFloat(this.price.toFixed(2));
|
281
282
|
} else {
|
@@ -283,15 +284,15 @@ const Product = function(productData) {
|
|
283
284
|
}
|
284
285
|
};
|
285
286
|
|
286
|
-
this.getOriginalPrice = function() {
|
287
|
+
this.getOriginalPrice = function () {
|
287
288
|
return this.priceType ? this.priceMap[this.priceType] : null;
|
288
289
|
};
|
289
290
|
|
290
|
-
this.addPricing = function(type, price) {
|
291
|
+
this.addPricing = function (type, price) {
|
291
292
|
this.priceMap[type] = price;
|
292
293
|
};
|
293
294
|
|
294
|
-
this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
|
295
|
+
this.addPricingFromStatus = function (productStatus, priceType, option = {}) {
|
295
296
|
let modified = false;
|
296
297
|
|
297
298
|
if (!priceType) {
|
@@ -326,7 +327,7 @@ const Product = function(productData) {
|
|
326
327
|
}, this);
|
327
328
|
}
|
328
329
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
|
329
|
-
if(productStatus.childSkus) {
|
330
|
+
if (productStatus.childSkus) {
|
330
331
|
this.childSkus = productStatus.childSkus;
|
331
332
|
}
|
332
333
|
this.setPriceAndPvFromType(priceType, null, option);
|
@@ -346,15 +347,15 @@ const Product = function(productData) {
|
|
346
347
|
return modified;
|
347
348
|
};
|
348
349
|
|
349
|
-
this.addPvWithType = function(type, pv) {
|
350
|
+
this.addPvWithType = function (type, pv) {
|
350
351
|
this.pvMap[type] = pv;
|
351
352
|
};
|
352
353
|
|
353
|
-
this.addCvWithType = function(type, cv) {
|
354
|
+
this.addCvWithType = function (type, cv) {
|
354
355
|
this.cvMap[type] = cv;
|
355
356
|
};
|
356
357
|
|
357
|
-
this.getPricing = function(type) {
|
358
|
+
this.getPricing = function (type) {
|
358
359
|
let retVal = null;
|
359
360
|
|
360
361
|
if (type) {
|
@@ -381,7 +382,7 @@ const Product = function(productData) {
|
|
381
382
|
return eventPriceTypes;
|
382
383
|
};
|
383
384
|
|
384
|
-
this.getPvWithType = function(type) {
|
385
|
+
this.getPvWithType = function (type) {
|
385
386
|
let rv = this.pvMap[type];
|
386
387
|
if (rv == null) {
|
387
388
|
// Assumption: we always have WWHL from the service
|
@@ -391,7 +392,7 @@ const Product = function(productData) {
|
|
391
392
|
return rv;
|
392
393
|
};
|
393
394
|
|
394
|
-
this.getCvWithType = function(type) {
|
395
|
+
this.getCvWithType = function (type) {
|
395
396
|
let rv = this.cvMap[type];
|
396
397
|
if (rv == null) {
|
397
398
|
rv = this.cvMap[PriceType.WWHL];
|
@@ -399,77 +400,77 @@ const Product = function(productData) {
|
|
399
400
|
return rv;
|
400
401
|
};
|
401
402
|
|
402
|
-
this.hasAdrOption = function() {
|
403
|
+
this.hasAdrOption = function () {
|
403
404
|
return this.orderTypes["adr"];
|
404
405
|
};
|
405
406
|
|
406
|
-
this.isAdrOnly = function() {
|
407
|
+
this.isAdrOnly = function () {
|
407
408
|
return this.hasAdrOption() && !this.hasOrderOption();
|
408
409
|
};
|
409
410
|
|
410
|
-
this.hasMultipleOrderTypes = function() {
|
411
|
+
this.hasMultipleOrderTypes = function () {
|
411
412
|
return this.hasOrderOption() && this.hasAdrOption();
|
412
413
|
};
|
413
414
|
|
414
|
-
this.hasOrderOption = function() {
|
415
|
+
this.hasOrderOption = function () {
|
415
416
|
return this.orderTypes["order"];
|
416
417
|
};
|
417
418
|
|
418
|
-
this.isDistributor = function() {
|
419
|
+
this.isDistributor = function () {
|
419
420
|
return this.custTypes.includes("10");
|
420
421
|
};
|
421
422
|
|
422
|
-
this.isCustomer = function() {
|
423
|
+
this.isCustomer = function () {
|
423
424
|
return this.custTypes.includes("20");
|
424
425
|
};
|
425
426
|
|
426
|
-
this.isPreferredCustomer = function() {
|
427
|
+
this.isPreferredCustomer = function () {
|
427
428
|
return this.custTypes.includes("30");
|
428
429
|
};
|
429
430
|
|
430
|
-
this.isBase = function() {
|
431
|
+
this.isBase = function () {
|
431
432
|
return this.sku.substring(2, 4) === "55";
|
432
433
|
};
|
433
434
|
|
434
|
-
this.isVariant = function() {
|
435
|
+
this.isVariant = function () {
|
435
436
|
return this.baseSku.length > 0 && this.variantSkus().length === 0;
|
436
437
|
};
|
437
438
|
|
438
|
-
this.setVariant = function(variantProduct) {
|
439
|
+
this.setVariant = function (variantProduct) {
|
439
440
|
if (variantProduct && variantProduct.sku) {
|
440
441
|
this.variants[variantProduct.sku] = variantProduct;
|
441
442
|
}
|
442
443
|
};
|
443
444
|
|
444
|
-
this.getVariant = function(sku) {
|
445
|
+
this.getVariant = function (sku) {
|
445
446
|
return this.variants[sku];
|
446
447
|
};
|
447
448
|
|
448
|
-
this.variantSkus = function() {
|
449
|
+
this.variantSkus = function () {
|
449
450
|
return Object.keys(this.variants);
|
450
451
|
};
|
451
452
|
|
452
|
-
this.getVariantsList = function() {
|
453
|
+
this.getVariantsList = function () {
|
453
454
|
return Object.values(this.variants);
|
454
455
|
};
|
455
456
|
|
456
|
-
this.getMinPrice = function() {
|
457
|
+
this.getMinPrice = function () {
|
457
458
|
return this.priceMap[`min-${this.priceType}`];
|
458
459
|
};
|
459
460
|
|
460
|
-
this.getMaxPrice = function() {
|
461
|
+
this.getMaxPrice = function () {
|
461
462
|
return this.priceMap[`max-${this.priceType}`];
|
462
463
|
};
|
463
464
|
|
464
|
-
this.getMinPv = function() {
|
465
|
+
this.getMinPv = function () {
|
465
466
|
return this.pvMap[`min-${this.priceType}`];
|
466
467
|
};
|
467
468
|
|
468
|
-
this.getMaxPv = function() {
|
469
|
+
this.getMaxPv = function () {
|
469
470
|
return this.pvMap[`max-${this.priceType}`];
|
470
471
|
};
|
471
472
|
|
472
|
-
this.toJSON = function() {
|
473
|
+
this.toJSON = function () {
|
473
474
|
let retData = {};
|
474
475
|
retData.sku = this.sku;
|
475
476
|
retData.globalProductID = this.globalProductID;
|
@@ -538,11 +539,11 @@ const Product = function(productData) {
|
|
538
539
|
return retData;
|
539
540
|
};
|
540
541
|
|
541
|
-
this.setMeCommerceProductData = function(/*productData*/) {
|
542
|
+
this.setMeCommerceProductData = function (/*productData*/) {
|
542
543
|
console.error("setMeCommerceProductData is deprecated!");
|
543
544
|
};
|
544
545
|
|
545
|
-
this.setBaseUrl = function(baseUrl) {
|
546
|
+
this.setBaseUrl = function (baseUrl) {
|
546
547
|
this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
|
547
548
|
this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
|
548
549
|
|
@@ -554,7 +555,7 @@ const Product = function(productData) {
|
|
554
555
|
}
|
555
556
|
};
|
556
557
|
|
557
|
-
this.setProductData = function(productData) {
|
558
|
+
this.setProductData = function (productData) {
|
558
559
|
let data;
|
559
560
|
|
560
561
|
if (productData) {
|
@@ -662,7 +663,7 @@ const Product = function(productData) {
|
|
662
663
|
? data.pvMap
|
663
664
|
: this.pvMap;
|
664
665
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
|
665
|
-
if(data.childSkus) {
|
666
|
+
if (data.childSkus) {
|
666
667
|
this.childSkus = data.childSkus;
|
667
668
|
}
|
668
669
|
this.custTypes = data.custTypes || [];
|
@@ -678,7 +679,7 @@ const Product = function(productData) {
|
|
678
679
|
}
|
679
680
|
};
|
680
681
|
|
681
|
-
this.isEmpty = function() {
|
682
|
+
this.isEmpty = function () {
|
682
683
|
return (
|
683
684
|
isFieldEmpty(this.sku) &&
|
684
685
|
isFieldEmpty(this.title) &&
|
package/src/productData.js
CHANGED
@@ -5,7 +5,7 @@ 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
|
-
const { mapAvailableQuantity
|
8
|
+
const { mapAvailableQuantity } = require('./equinox-helpers');
|
9
9
|
|
10
10
|
const productTypes = {
|
11
11
|
kit: 'kit'
|
@@ -66,6 +66,7 @@ const ProductData = {
|
|
66
66
|
}
|
67
67
|
|
68
68
|
const filter = skuFilter.join(" OR ")
|
69
|
+
//axios.defaults.withCredentials = true;
|
69
70
|
|
70
71
|
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
71
72
|
const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
|
@@ -128,13 +129,21 @@ const ProductData = {
|
|
128
129
|
*/
|
129
130
|
eqProductVariantMapper: function (eqVariant) {
|
130
131
|
|
131
|
-
let imageURL = eqVariant.properties.imageURL
|
132
|
-
|
132
|
+
let imageURL = eqVariant.properties.imageURL;
|
133
|
+
const regex = /\d+\.\d+/
|
134
|
+
let thumbnailImage = ''
|
133
135
|
|
136
|
+
if (imageURL.includes('contentstack')) {
|
137
|
+
thumbnailImage = imageURL + '?width=40'
|
138
|
+
} else {
|
139
|
+
thumbnailImage = imageURL.replace(regex, '40.40')
|
140
|
+
}
|
134
141
|
|
135
|
-
const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
|
142
|
+
const { eventName, eventLabels, computedPrice, defaultProductPrice, CVPrice, PVPrice } = this.getEqProductPromotions(eqVariant);
|
136
143
|
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
137
144
|
const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
|
145
|
+
const productCVPrice = eventName ? CVPrice : eqVariant.priceFacets.CV;
|
146
|
+
const productPVPrice = eventName ? PVPrice : eqVariant.priceFacets.PV;
|
138
147
|
|
139
148
|
return {
|
140
149
|
"sku": eqVariant.identifier,
|
@@ -241,8 +250,8 @@ const ProductData = {
|
|
241
250
|
"availableQuantity": eqVariant.inventoryProperties.atpQty,
|
242
251
|
"maxQuantity": 999,
|
243
252
|
"points": "",
|
244
|
-
"cv":
|
245
|
-
"pv":
|
253
|
+
"cv": productCVPrice,
|
254
|
+
"pv": productPVPrice,
|
246
255
|
"priceType": "WRTL",
|
247
256
|
"price": discountedPrice,
|
248
257
|
"priceMap": {
|
@@ -255,14 +264,14 @@ const ProductData = {
|
|
255
264
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
256
265
|
},
|
257
266
|
"cvMap": {
|
258
|
-
"WWHL":
|
259
|
-
"WADW":
|
260
|
-
"WHL":
|
267
|
+
"WWHL": productCVPrice,
|
268
|
+
"WADW": productCVPrice,
|
269
|
+
"WHL": productCVPrice
|
261
270
|
},
|
262
271
|
"pvMap": {
|
263
|
-
"WWHL":
|
264
|
-
"WADW":
|
265
|
-
"WHL":
|
272
|
+
"WWHL": productPVPrice,
|
273
|
+
"WADW": productPVPrice,
|
274
|
+
"WHL": productPVPrice
|
266
275
|
},
|
267
276
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
268
277
|
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
@@ -295,7 +304,8 @@ const ProductData = {
|
|
295
304
|
},
|
296
305
|
"restrictedMarkets": [],
|
297
306
|
"addOns": [],
|
298
|
-
"equinoxProductId": eqVariant.identifier
|
307
|
+
"equinoxProductId": eqVariant.identifier,
|
308
|
+
"variantDefault": eqVariant.default
|
299
309
|
};
|
300
310
|
},
|
301
311
|
|
@@ -319,6 +329,16 @@ const ProductData = {
|
|
319
329
|
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
|
320
330
|
? product.totalValue.priceAfterDiscount
|
321
331
|
: 0;
|
332
|
+
|
333
|
+
let CVPrice = 0,
|
334
|
+
PVPrice = 0;
|
335
|
+
|
336
|
+
if(product.totalValue && product.totalValue.priceFacets) {
|
337
|
+
const productPriceFacets = product.totalValue.priceFacets;
|
338
|
+
CVPrice = productPriceFacets.CV && productPriceFacets.CV.CVAfterDiscount ? productPriceFacets.CV.CVAfterDiscount : 0;
|
339
|
+
PVPrice = productPriceFacets.PV && productPriceFacets.PV.PVAfterDiscount ? productPriceFacets.PV.PVAfterDiscount : 0;
|
340
|
+
}
|
341
|
+
|
322
342
|
let eventName = "";
|
323
343
|
const eventLabels = [];
|
324
344
|
|
@@ -332,141 +352,152 @@ const ProductData = {
|
|
332
352
|
eventLabels: eventLabels.join(','),
|
333
353
|
defaultProductPrice,
|
334
354
|
computedPrice,
|
335
|
-
eventName
|
355
|
+
eventName,
|
356
|
+
CVPrice,
|
357
|
+
PVPrice
|
336
358
|
}
|
337
359
|
},
|
338
360
|
|
361
|
+
|
339
362
|
eqProductMapper: async function (productDataResponse, skus) {
|
363
|
+
// console.log(productDataResponse, skus);
|
340
364
|
let count = 0;
|
341
365
|
const products = [];
|
342
366
|
|
343
367
|
for (const productData of productDataResponse) {
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
});
|
357
|
-
}
|
368
|
+
let variants = {};
|
369
|
+
|
370
|
+
let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
|
371
|
+
let imageURL = product.properties.imageURL;
|
372
|
+
const regex = /\d+\.\d+/
|
373
|
+
let thumbnailImage = ''
|
374
|
+
|
375
|
+
if (imageURL.includes('contentstack')) {
|
376
|
+
thumbnailImage = imageURL + '?width=40'
|
377
|
+
} else {
|
378
|
+
thumbnailImage = imageURL.replace(regex, '40.40')
|
379
|
+
}
|
358
380
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
}
|
365
|
-
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
366
|
-
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
367
|
-
|
368
|
-
product.childSkus = await this.fetchChildSkus(product);
|
369
|
-
product.availableQuantity = mapAvailableQuantity(product);
|
370
|
-
product = {
|
371
|
-
...product,
|
372
|
-
"sku": product.identifier,
|
373
|
-
"globalProductID": productData.identifier,
|
374
|
-
"title": productData.properties.name,
|
375
|
-
"country": product.properties.market,
|
376
|
-
"language": "en",
|
377
|
-
"shortDescr": productData.properties.description,
|
378
|
-
"longDescr": productData.properties.productDetailsDescription,
|
379
|
-
"fullImage": imageURL,
|
380
|
-
"imageAltText": productData.properties.name,
|
381
|
-
"productCarouselImages": [
|
382
|
-
{
|
383
|
-
"contentType": "img",
|
384
|
-
"src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
|
385
|
-
"alt": ""
|
386
|
-
}
|
387
|
-
],
|
388
|
-
"thumbnail": thumbnailImage,
|
389
|
-
"ingredients": productData.properties.ingredients,
|
390
|
-
"benefits": productData.properties.benefits,
|
391
|
-
"usage": productData.properties.usage,
|
392
|
-
"resources": product.properties.resources,
|
393
|
-
"videos": "",
|
394
|
-
"movie": "",
|
395
|
-
"youtube": "",
|
396
|
-
"salesEventText": "",
|
397
|
-
"contentSection": [
|
398
|
-
{
|
399
|
-
"sectionContent": "<div class=\"contentSections\"></div>\n"
|
400
|
-
}
|
401
|
-
],
|
402
|
-
"scanQualified": productData.properties.scanQualifiedCount,
|
403
|
-
"maxQuantity": 999,
|
404
|
-
"points": "",
|
405
|
-
"cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
406
|
-
"pv": product.priceFacets.PV,
|
407
|
-
"priceType": "WRTL",
|
408
|
-
"price": discountedPrice,
|
409
|
-
"priceMap": {
|
410
|
-
"WRTL": productPrice,
|
411
|
-
"WADW-WRTL": product.priceFacets["Regular Price"],
|
412
|
-
"WADR": product.priceFacets["Regular Price"],
|
413
|
-
"RTL": product.priceFacets["Regular Price"],
|
414
|
-
"WADW": product.priceFacets["Wholesale Price"],
|
415
|
-
"WHL": product.priceFacets["Wholesale Price"],
|
416
|
-
"WWHL": product.priceFacets["Wholesale Price"]
|
417
|
-
},
|
418
|
-
"cvMap": {
|
419
|
-
"WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
420
|
-
"WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
421
|
-
"WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
|
422
|
-
},
|
423
|
-
"pvMap": {
|
424
|
-
"WWHL": product.priceFacets.PV,
|
425
|
-
"WADW": product.priceFacets.PV,
|
426
|
-
"WHL": product.priceFacets.PV
|
427
|
-
},
|
428
|
-
"orderTypes": this._setOrderType(product.properties),
|
429
|
-
"custTypes": this.switchCustType(product.properties.customerTypes),
|
430
|
-
"division": productData.properties.division,
|
431
|
-
"backOrderDate": null,
|
432
|
-
"locallyProduced": false,
|
433
|
-
"agelocme": null,
|
434
|
-
"count": "",
|
435
|
-
"flavor": "",
|
436
|
-
"size": product.properties.size,
|
437
|
-
"shade": "",
|
438
|
-
"status": this.switchStatusFromEquinox(product.properties.productStatus),
|
439
|
-
"variantType": "Other",
|
440
|
-
"variantDropdownLabel": product.properties.variantLabel || "",
|
441
|
-
"variantDropdownPlaceholder": "Select Type",
|
442
|
-
"variantsLabel": product.properties.variantLabel || "",
|
443
|
-
"groupOffer": false,
|
444
|
-
"personalOffer": false,
|
445
|
-
"savedEventName": eventName,
|
446
|
-
"salesLabel": eventLabels,
|
447
|
-
"eventName": eventName,
|
448
|
-
"sizeWeight": '',
|
449
|
-
"nettoWeight": "",
|
450
|
-
"variants": variants,
|
451
|
-
"searchScore": 0,
|
452
|
-
"isExclusive": product.properties.isExclusive || false,
|
453
|
-
"marketAttributes": {
|
454
|
-
"discount": true,
|
455
|
-
"redeem": true,
|
456
|
-
"earn": true
|
457
|
-
},
|
458
|
-
"restrictedMarkets": [],
|
459
|
-
"addOns": [],
|
460
|
-
"inventory": product.inventory || "", //inventory label
|
461
|
-
"equinoxProductId": productData.identifier
|
462
|
-
};
|
463
|
-
|
464
|
-
products.push(new Product(product));
|
465
|
-
} catch (err) {
|
466
|
-
console.error('Unable to map the product', productData.identifier, ':', err);
|
467
|
-
console.error('Product info:', productDataResponse, skus);
|
468
|
-
continue;
|
381
|
+
if (productData.sku && productData.sku.length > 1) {
|
382
|
+
// exclude base product from variants
|
383
|
+
productData.sku.filter(v => v.identifier.substring(2, 4) !== "55").map(variant => {
|
384
|
+
variants[variant.identifier] = this.eqProductVariantMapper(variant);
|
385
|
+
return variant;
|
386
|
+
});
|
469
387
|
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
const {
|
392
|
+
eventName,
|
393
|
+
eventLabels,
|
394
|
+
computedPrice,
|
395
|
+
defaultProductPrice,
|
396
|
+
CVPrice,
|
397
|
+
PVPrice
|
398
|
+
} = this.getEqProductPromotions(product);
|
399
|
+
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
400
|
+
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
401
|
+
const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
|
402
|
+
const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
|
403
|
+
|
404
|
+
product.childSkus = await this.fetchChildSkus(product);
|
405
|
+
product.availableQuantity = mapAvailableQuantity(product);
|
406
|
+
product = {
|
407
|
+
...product,
|
408
|
+
"sku": product.identifier,
|
409
|
+
"globalProductID": productData.identifier,
|
410
|
+
"title": productData.properties.name,
|
411
|
+
"country": product.properties.market,
|
412
|
+
"language": "en",
|
413
|
+
"shortDescr": productData.properties.description,
|
414
|
+
"longDescr": productData.properties.productDetailsDescription,
|
415
|
+
"fullImage": imageURL,
|
416
|
+
"imageAltText": productData.properties.name,
|
417
|
+
"productCarouselImages": [
|
418
|
+
{
|
419
|
+
"contentType": "img",
|
420
|
+
"src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
|
421
|
+
"alt": ""
|
422
|
+
}
|
423
|
+
],
|
424
|
+
"thumbnail": thumbnailImage,
|
425
|
+
"ingredients": productData.properties.ingredients,
|
426
|
+
"benefits": productData.properties.benefits,
|
427
|
+
"usage": productData.properties.usage,
|
428
|
+
"resources": product.properties.resources,
|
429
|
+
"videos": "",
|
430
|
+
"movie": "",
|
431
|
+
"youtube": "",
|
432
|
+
"salesEventText": "",
|
433
|
+
"contentSection": [
|
434
|
+
{
|
435
|
+
"sectionContent": "<div class=\"contentSections\"></div>\n"
|
436
|
+
}
|
437
|
+
],
|
438
|
+
"scanQualified": productData.properties.scanQualifiedCount,
|
439
|
+
"maxQuantity": 999,
|
440
|
+
"points": "",
|
441
|
+
"cv": productCVPrice,
|
442
|
+
"pv": productPVPrice,
|
443
|
+
"priceType": "WRTL",
|
444
|
+
"price": discountedPrice,
|
445
|
+
"priceMap": {
|
446
|
+
"WRTL": parseInt(productPrice),
|
447
|
+
"WADW-WRTL": parseInt(product.priceFacets["Regular Price"]),
|
448
|
+
"WADR": parseInt(product.priceFacets["Regular Price"]),
|
449
|
+
"RTL": parseInt(product.priceFacets["Regular Price"]),
|
450
|
+
"WADW": parseInt(product.priceFacets["Wholesale Price"]),
|
451
|
+
"WHL": parseInt(product.priceFacets["Wholesale Price"]),
|
452
|
+
"WWHL": parseInt(product.priceFacets["Wholesale Price"])
|
453
|
+
},
|
454
|
+
"cvMap": {
|
455
|
+
"WWHL": productCVPrice,
|
456
|
+
"WADW": productCVPrice,
|
457
|
+
"WHL": productCVPrice
|
458
|
+
},
|
459
|
+
"pvMap": {
|
460
|
+
"WWHL": productPVPrice,
|
461
|
+
"WADW": productPVPrice,
|
462
|
+
"WHL": productPVPrice
|
463
|
+
},
|
464
|
+
"orderTypes": this._setOrderType(product.properties),
|
465
|
+
"custTypes": this.switchCustType(product.properties.customerTypes),
|
466
|
+
"division": productData.properties.division,
|
467
|
+
"backOrderDate": null,
|
468
|
+
"locallyProduced": false,
|
469
|
+
"agelocme": null,
|
470
|
+
"count": "",
|
471
|
+
"flavor": "",
|
472
|
+
"size": product.properties.size,
|
473
|
+
"shade": "",
|
474
|
+
"status": this.switchStatusFromEquinox(product.properties.productStatus),
|
475
|
+
"variantType": "Other",
|
476
|
+
"variantDropdownLabel": product.properties.variantLabel || "",
|
477
|
+
"variantDropdownPlaceholder": "Select Type",
|
478
|
+
"variantsLabel": product.properties.variantLabel || "",
|
479
|
+
"groupOffer": false,
|
480
|
+
"personalOffer": false,
|
481
|
+
"savedEventName": eventName,
|
482
|
+
"salesLabel": eventLabels,
|
483
|
+
"eventName": eventName,
|
484
|
+
"sizeWeight": '',
|
485
|
+
"nettoWeight": "",
|
486
|
+
"variants": variants,
|
487
|
+
"searchScore": 0,
|
488
|
+
"isExclusive": product.properties.isExclusive || false,
|
489
|
+
"marketAttributes": {
|
490
|
+
"discount": true,
|
491
|
+
"redeem": true,
|
492
|
+
"earn": true
|
493
|
+
},
|
494
|
+
"restrictedMarkets": [],
|
495
|
+
"addOns": [],
|
496
|
+
"inventory": product.inventory || "", //inventory label
|
497
|
+
"equinoxProductId": productData.identifier
|
498
|
+
};
|
499
|
+
|
500
|
+
products.push(new Product(product));
|
470
501
|
}
|
471
502
|
|
472
503
|
let data = {
|
@@ -509,7 +540,7 @@ const ProductData = {
|
|
509
540
|
type: 'SKUKIT',
|
510
541
|
availableChannels: product.properties.availableChannels
|
511
542
|
},
|
512
|
-
...res.data.product.map(p =>
|
543
|
+
...res.data.product.map(p => this.buildChildSkus(kits, p))
|
513
544
|
];
|
514
545
|
|
515
546
|
return childSkus;
|
@@ -518,6 +549,23 @@ const ProductData = {
|
|
518
549
|
return [];
|
519
550
|
},
|
520
551
|
|
552
|
+
buildChildSkus: function (kits, product) {
|
553
|
+
const sku = product.sku[0];
|
554
|
+
const kit = kits.filter(k => k.sku === sku.identifier)[0];
|
555
|
+
|
556
|
+
return {
|
557
|
+
productId: product.identifier,
|
558
|
+
skuId: sku.identifier,
|
559
|
+
type: 'MANDATORY',
|
560
|
+
skuQuantity: kit.qty,
|
561
|
+
availableChannels: sku.properties.availableChannels,
|
562
|
+
inventory: {
|
563
|
+
atpQty: sku.inventoryProperties.atpQty,
|
564
|
+
backOrdered: sku.inventoryProperties.backOrdered
|
565
|
+
}
|
566
|
+
}
|
567
|
+
},
|
568
|
+
|
521
569
|
/**
|
522
570
|
*
|
523
571
|
* Map status from equinox to legacy
|
@@ -1,31 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* childSKU maps a product variant. Used mainly in subscription.
|
3
|
-
*
|
4
|
-
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
-
* @param {import('.').EquinoxProduct} product
|
6
|
-
*/
|
7
|
-
function childSKU(kits, product) {
|
8
|
-
const sku = product.sku.filter(sku => sku.default)[0];
|
9
|
-
if (!sku) {
|
10
|
-
throw Error('Unable to find the default SKU.');
|
11
|
-
}
|
12
|
-
|
13
|
-
const kit = kits.filter(k => k.sku === sku.identifier)[0];
|
14
|
-
if (!kit) {
|
15
|
-
throw Error('SKU kit does not exist in the list of available variants.');
|
16
|
-
}
|
17
|
-
|
18
|
-
return {
|
19
|
-
productId: product.identifier,
|
20
|
-
skuId: sku.identifier,
|
21
|
-
type: 'MANDATORY',
|
22
|
-
skuQuantity: kit.qty,
|
23
|
-
availableChannels: sku.properties.availableChannels,
|
24
|
-
inventory: {
|
25
|
-
atpQty: sku.inventoryProperties.atpQty,
|
26
|
-
backOrdered: sku.inventoryProperties.backOrdered
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
module.exports = childSKU;
|