@nuskin/ns-product-lib 2.6.2-cx24-3563.2 → 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 +88 -16
- package/package.json +1 -1
- package/src/equinox-helpers/availableQuantity.js +2 -2
- package/src/equinox-helpers/index.js +4 -43
- package/src/product.js +63 -68
- package/src/productData.js +162 -134
- package/src/equinox-helpers/childSKU.js +0 -31
package/CHANGELOG.md
CHANGED
@@ -1,53 +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
|
-
*
|
7
|
-
* Discounted PV CV are not displayed in MySite admin and home pages ([b1684da](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b1684dada7851f910548e29ec1e2463cca55c738))
|
6
|
+
* Lint Errors after merge ([86f07a8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/86f07a8b27e5f772d364ec40c1c0014f534f0312))
|
8
7
|
|
9
|
-
|
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)
|
10
80
|
|
11
81
|
|
12
82
|
### Fix
|
13
83
|
|
14
|
-
*
|
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))
|
15
86
|
|
16
|
-
## [2.6.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.
|
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)
|
17
88
|
|
18
89
|
|
19
90
|
### Fix
|
20
91
|
|
21
|
-
*
|
92
|
+
* The variant drop down label ([2e175c1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2e175c12f24b789f913e64fff5e26b3257ccd087))
|
22
93
|
|
23
|
-
## [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)
|
24
95
|
|
25
96
|
|
26
97
|
### Fix
|
27
98
|
|
28
|
-
* 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))
|
29
100
|
|
30
|
-
## [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)
|
31
102
|
|
32
103
|
|
33
104
|
### Fix
|
34
105
|
|
35
|
-
*
|
106
|
+
* The variant drop down label ([707ddb3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/707ddb37391363059c86460e5da575b78409e250))
|
36
107
|
|
37
|
-
## [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)
|
38
109
|
|
39
110
|
|
40
111
|
### Fix
|
41
112
|
|
42
|
-
*
|
113
|
+
* The variant drop down label ([973f145](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/973f1455a91127d575a8fc7d26e7e78d05f1f0a4))
|
43
114
|
|
44
|
-
## [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)
|
45
116
|
|
46
117
|
|
47
118
|
### Fix
|
48
119
|
|
49
|
-
*
|
50
|
-
*
|
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))
|
51
123
|
|
52
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)
|
53
125
|
|
package/package.json
CHANGED
@@ -8,8 +8,8 @@ function availableQuantity(product) {
|
|
8
8
|
return product.inventoryProperties.atpQty;
|
9
9
|
}
|
10
10
|
|
11
|
-
if (product.
|
12
|
-
const quantities = product.
|
11
|
+
if (product.childSkus && product.childSkus.length > 0) {
|
12
|
+
const quantities = product.childSkus
|
13
13
|
.filter(cs => cs.inventory !== undefined)
|
14
14
|
.map(cs => cs.inventory.atpQty);
|
15
15
|
|
@@ -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,15 +76,15 @@ const Product = function(productData) {
|
|
76
76
|
//@example "IN STOCK"
|
77
77
|
this.inventory = "";
|
78
78
|
this.equinoxProductId = "";
|
79
|
-
this.
|
79
|
+
this.variantDefault = false;
|
80
80
|
|
81
|
-
this.setMarketAttributes = function(productStatus) {
|
81
|
+
this.setMarketAttributes = function (productStatus) {
|
82
82
|
if (productStatus.marketAttributes) {
|
83
83
|
this.marketAttributes = productStatus.marketAttributes;
|
84
84
|
}
|
85
85
|
};
|
86
86
|
|
87
|
-
this.getAgelocmeKeyPart = function() {
|
87
|
+
this.getAgelocmeKeyPart = function () {
|
88
88
|
let keyPart = null;
|
89
89
|
if (this.agelocme) {
|
90
90
|
keyPart =
|
@@ -98,27 +98,27 @@ const Product = function(productData) {
|
|
98
98
|
return keyPart;
|
99
99
|
};
|
100
100
|
|
101
|
-
this.getHighlightedSku = function() {
|
101
|
+
this.getHighlightedSku = function () {
|
102
102
|
let rv = this.sku;
|
103
103
|
if (this.highlightedSku) rv = this.highlightedSku;
|
104
104
|
return rv;
|
105
105
|
};
|
106
106
|
|
107
|
-
this.getProductSearchTitle = function() {
|
107
|
+
this.getProductSearchTitle = function () {
|
108
108
|
if (this.agelocme && this.agelocme.label) {
|
109
109
|
return this.agelocme.label;
|
110
110
|
}
|
111
111
|
return this.title;
|
112
112
|
};
|
113
113
|
|
114
|
-
this.getProductSearchSku = function() {
|
114
|
+
this.getProductSearchSku = function () {
|
115
115
|
if (this.agelocme && this.agelocme.code) {
|
116
116
|
return this.agelocme.code;
|
117
117
|
}
|
118
118
|
return this.getHighlightedSku();
|
119
119
|
};
|
120
120
|
|
121
|
-
this.getDescription = function() {
|
121
|
+
this.getDescription = function () {
|
122
122
|
let description = this.longDescr;
|
123
123
|
if (!description || description.length === 0) {
|
124
124
|
return this.shortDescr;
|
@@ -126,7 +126,7 @@ const Product = function(productData) {
|
|
126
126
|
return description;
|
127
127
|
};
|
128
128
|
|
129
|
-
this.setFullImage = function(fullImage) {
|
129
|
+
this.setFullImage = function (fullImage) {
|
130
130
|
if (fullImage) {
|
131
131
|
this.fullImage = fullImage.replace("http:", "https:");
|
132
132
|
} else {
|
@@ -134,19 +134,19 @@ const Product = function(productData) {
|
|
134
134
|
}
|
135
135
|
};
|
136
136
|
|
137
|
-
this.getFullImage = function() {
|
137
|
+
this.getFullImage = function () {
|
138
138
|
return this.fullImage ? this.fullImage.replace("http:", "https:") : "";
|
139
139
|
};
|
140
140
|
|
141
|
-
this.setProductCarouselImages = function(productCarouselImages) {
|
141
|
+
this.setProductCarouselImages = function (productCarouselImages) {
|
142
142
|
this.productCarouselImages = productCarouselImages;
|
143
143
|
};
|
144
144
|
|
145
|
-
this.getProductCarouselImages = function() {
|
145
|
+
this.getProductCarouselImages = function () {
|
146
146
|
return this.productCarouselImages;
|
147
147
|
};
|
148
148
|
|
149
|
-
this.setImageAltText = function(altText) {
|
149
|
+
this.setImageAltText = function (altText) {
|
150
150
|
if (altText) {
|
151
151
|
this.imageAltText = altText;
|
152
152
|
} else {
|
@@ -154,11 +154,11 @@ const Product = function(productData) {
|
|
154
154
|
}
|
155
155
|
};
|
156
156
|
|
157
|
-
this.getImageAltText = function() {
|
157
|
+
this.getImageAltText = function () {
|
158
158
|
return this.imageAltText || this.title;
|
159
159
|
};
|
160
160
|
|
161
|
-
this.setThumbnail = function(thumbnail) {
|
161
|
+
this.setThumbnail = function (thumbnail) {
|
162
162
|
if (thumbnail) {
|
163
163
|
this.thumbnail = thumbnail.replace("http:", "https:");
|
164
164
|
} else {
|
@@ -166,7 +166,7 @@ const Product = function(productData) {
|
|
166
166
|
}
|
167
167
|
};
|
168
168
|
|
169
|
-
this.setThumbnailFromSku = function(sku) {
|
169
|
+
this.setThumbnailFromSku = function (sku) {
|
170
170
|
// WARNING: Base URL will need to be handled in the client (call setBaseUrl)
|
171
171
|
// eslint-disable-next-line max-len
|
172
172
|
// this.thumbnail = `${RunConfigService.getBaseUrl()}/content/products/${ProductUtils.getTokenizedSku(sku)}/jcr:content/fullImage.img.100.100.png`;
|
@@ -176,43 +176,43 @@ const Product = function(productData) {
|
|
176
176
|
)}/jcr:content/fullImage.img.100.100.png`;
|
177
177
|
};
|
178
178
|
|
179
|
-
this.getThumbnail = function() {
|
179
|
+
this.getThumbnail = function () {
|
180
180
|
return this.thumbnail ? this.thumbnail.replace("http:", "https:") : "";
|
181
181
|
};
|
182
182
|
|
183
|
-
this.hasAvailableQuantity = function(qty = 1) {
|
183
|
+
this.hasAvailableQuantity = function (qty = 1) {
|
184
184
|
return Math.min(this.maxQuantity, this.availableQuantity) >= qty;
|
185
185
|
};
|
186
186
|
|
187
|
-
this.setPoints = function(points) {
|
187
|
+
this.setPoints = function (points) {
|
188
188
|
this.points = ensureFloatVal(points) || "";
|
189
189
|
};
|
190
190
|
|
191
|
-
this.getPointsFixed = function() {
|
191
|
+
this.getPointsFixed = function () {
|
192
192
|
return parseFloat(this.points).toFixed(2);
|
193
193
|
};
|
194
194
|
|
195
|
-
this.setCv = function(cv) {
|
195
|
+
this.setCv = function (cv) {
|
196
196
|
this.cv = ensureFloatVal(cv) || "";
|
197
197
|
};
|
198
198
|
|
199
|
-
this.getCvFixed = function() {
|
199
|
+
this.getCvFixed = function () {
|
200
200
|
return parseFloat(this.cv).toFixed(2);
|
201
201
|
};
|
202
202
|
|
203
|
-
this.setPv = function(pv) {
|
203
|
+
this.setPv = function (pv) {
|
204
204
|
this.pv = ensureFloatVal(pv) || "";
|
205
205
|
};
|
206
206
|
|
207
|
-
this.getPvFixed = function() {
|
207
|
+
this.getPvFixed = function () {
|
208
208
|
return parseFloat(this.pv || 0).toFixed(2);
|
209
209
|
};
|
210
210
|
|
211
|
-
this.setPrice = function(price) {
|
211
|
+
this.setPrice = function (price) {
|
212
212
|
this.price = ensureFloatVal(price, true);
|
213
213
|
};
|
214
214
|
|
215
|
-
this.setFormattedPrice = function(formattedPrice) {
|
215
|
+
this.setFormattedPrice = function (formattedPrice) {
|
216
216
|
this.formattedPrice = formattedPrice;
|
217
217
|
};
|
218
218
|
|
@@ -221,13 +221,13 @@ const Product = function(productData) {
|
|
221
221
|
* added to the cart the event pricing needs to be remembered if toggling between
|
222
222
|
* pricetypes with event pricing and pricetype without event pricing
|
223
223
|
*/
|
224
|
-
this.lockEventName = function() {
|
224
|
+
this.lockEventName = function () {
|
225
225
|
if (!this.savedEventName && this.eventName) {
|
226
226
|
this.savedEventName = this.eventName;
|
227
227
|
}
|
228
228
|
};
|
229
229
|
|
230
|
-
this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
|
230
|
+
this.setPriceAndPvFromType = function (_priceType, _activeEvents = null, option = {}) {
|
231
231
|
// WARNING: priceType needs to be handled client-side
|
232
232
|
// const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
|
233
233
|
// ? PriceType.WWHL
|
@@ -272,11 +272,11 @@ const Product = function(productData) {
|
|
272
272
|
return changed;
|
273
273
|
};
|
274
274
|
|
275
|
-
this.getPrice = function() {
|
275
|
+
this.getPrice = function () {
|
276
276
|
return this.price ? this.price : 0;
|
277
277
|
};
|
278
278
|
|
279
|
-
this.getPriceFixed = function() {
|
279
|
+
this.getPriceFixed = function () {
|
280
280
|
if (typeof this.price === "number") {
|
281
281
|
return parseFloat(this.price.toFixed(2));
|
282
282
|
} else {
|
@@ -284,15 +284,15 @@ const Product = function(productData) {
|
|
284
284
|
}
|
285
285
|
};
|
286
286
|
|
287
|
-
this.getOriginalPrice = function() {
|
287
|
+
this.getOriginalPrice = function () {
|
288
288
|
return this.priceType ? this.priceMap[this.priceType] : null;
|
289
289
|
};
|
290
290
|
|
291
|
-
this.addPricing = function(type, price) {
|
291
|
+
this.addPricing = function (type, price) {
|
292
292
|
this.priceMap[type] = price;
|
293
293
|
};
|
294
294
|
|
295
|
-
this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
|
295
|
+
this.addPricingFromStatus = function (productStatus, priceType, option = {}) {
|
296
296
|
let modified = false;
|
297
297
|
|
298
298
|
if (!priceType) {
|
@@ -327,7 +327,7 @@ const Product = function(productData) {
|
|
327
327
|
}, this);
|
328
328
|
}
|
329
329
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
|
330
|
-
if(productStatus.childSkus) {
|
330
|
+
if (productStatus.childSkus) {
|
331
331
|
this.childSkus = productStatus.childSkus;
|
332
332
|
}
|
333
333
|
this.setPriceAndPvFromType(priceType, null, option);
|
@@ -347,15 +347,15 @@ const Product = function(productData) {
|
|
347
347
|
return modified;
|
348
348
|
};
|
349
349
|
|
350
|
-
this.addPvWithType = function(type, pv) {
|
350
|
+
this.addPvWithType = function (type, pv) {
|
351
351
|
this.pvMap[type] = pv;
|
352
352
|
};
|
353
353
|
|
354
|
-
this.addCvWithType = function(type, cv) {
|
354
|
+
this.addCvWithType = function (type, cv) {
|
355
355
|
this.cvMap[type] = cv;
|
356
356
|
};
|
357
357
|
|
358
|
-
this.getPricing = function(type) {
|
358
|
+
this.getPricing = function (type) {
|
359
359
|
let retVal = null;
|
360
360
|
|
361
361
|
if (type) {
|
@@ -382,7 +382,7 @@ const Product = function(productData) {
|
|
382
382
|
return eventPriceTypes;
|
383
383
|
};
|
384
384
|
|
385
|
-
this.getPvWithType = function(type) {
|
385
|
+
this.getPvWithType = function (type) {
|
386
386
|
let rv = this.pvMap[type];
|
387
387
|
if (rv == null) {
|
388
388
|
// Assumption: we always have WWHL from the service
|
@@ -392,7 +392,7 @@ const Product = function(productData) {
|
|
392
392
|
return rv;
|
393
393
|
};
|
394
394
|
|
395
|
-
this.getCvWithType = function(type) {
|
395
|
+
this.getCvWithType = function (type) {
|
396
396
|
let rv = this.cvMap[type];
|
397
397
|
if (rv == null) {
|
398
398
|
rv = this.cvMap[PriceType.WWHL];
|
@@ -400,77 +400,77 @@ const Product = function(productData) {
|
|
400
400
|
return rv;
|
401
401
|
};
|
402
402
|
|
403
|
-
this.hasAdrOption = function() {
|
403
|
+
this.hasAdrOption = function () {
|
404
404
|
return this.orderTypes["adr"];
|
405
405
|
};
|
406
406
|
|
407
|
-
this.isAdrOnly = function() {
|
407
|
+
this.isAdrOnly = function () {
|
408
408
|
return this.hasAdrOption() && !this.hasOrderOption();
|
409
409
|
};
|
410
410
|
|
411
|
-
this.hasMultipleOrderTypes = function() {
|
411
|
+
this.hasMultipleOrderTypes = function () {
|
412
412
|
return this.hasOrderOption() && this.hasAdrOption();
|
413
413
|
};
|
414
414
|
|
415
|
-
this.hasOrderOption = function() {
|
415
|
+
this.hasOrderOption = function () {
|
416
416
|
return this.orderTypes["order"];
|
417
417
|
};
|
418
418
|
|
419
|
-
this.isDistributor = function() {
|
419
|
+
this.isDistributor = function () {
|
420
420
|
return this.custTypes.includes("10");
|
421
421
|
};
|
422
422
|
|
423
|
-
this.isCustomer = function() {
|
423
|
+
this.isCustomer = function () {
|
424
424
|
return this.custTypes.includes("20");
|
425
425
|
};
|
426
426
|
|
427
|
-
this.isPreferredCustomer = function() {
|
427
|
+
this.isPreferredCustomer = function () {
|
428
428
|
return this.custTypes.includes("30");
|
429
429
|
};
|
430
430
|
|
431
|
-
this.isBase = function() {
|
431
|
+
this.isBase = function () {
|
432
432
|
return this.sku.substring(2, 4) === "55";
|
433
433
|
};
|
434
434
|
|
435
|
-
this.isVariant = function() {
|
435
|
+
this.isVariant = function () {
|
436
436
|
return this.baseSku.length > 0 && this.variantSkus().length === 0;
|
437
437
|
};
|
438
438
|
|
439
|
-
this.setVariant = function(variantProduct) {
|
439
|
+
this.setVariant = function (variantProduct) {
|
440
440
|
if (variantProduct && variantProduct.sku) {
|
441
441
|
this.variants[variantProduct.sku] = variantProduct;
|
442
442
|
}
|
443
443
|
};
|
444
444
|
|
445
|
-
this.getVariant = function(sku) {
|
445
|
+
this.getVariant = function (sku) {
|
446
446
|
return this.variants[sku];
|
447
447
|
};
|
448
448
|
|
449
|
-
this.variantSkus = function() {
|
449
|
+
this.variantSkus = function () {
|
450
450
|
return Object.keys(this.variants);
|
451
451
|
};
|
452
452
|
|
453
|
-
this.getVariantsList = function() {
|
453
|
+
this.getVariantsList = function () {
|
454
454
|
return Object.values(this.variants);
|
455
455
|
};
|
456
456
|
|
457
|
-
this.getMinPrice = function() {
|
457
|
+
this.getMinPrice = function () {
|
458
458
|
return this.priceMap[`min-${this.priceType}`];
|
459
459
|
};
|
460
460
|
|
461
|
-
this.getMaxPrice = function() {
|
461
|
+
this.getMaxPrice = function () {
|
462
462
|
return this.priceMap[`max-${this.priceType}`];
|
463
463
|
};
|
464
464
|
|
465
|
-
this.getMinPv = function() {
|
465
|
+
this.getMinPv = function () {
|
466
466
|
return this.pvMap[`min-${this.priceType}`];
|
467
467
|
};
|
468
468
|
|
469
|
-
this.getMaxPv = function() {
|
469
|
+
this.getMaxPv = function () {
|
470
470
|
return this.pvMap[`max-${this.priceType}`];
|
471
471
|
};
|
472
472
|
|
473
|
-
this.toJSON = function() {
|
473
|
+
this.toJSON = function () {
|
474
474
|
let retData = {};
|
475
475
|
retData.sku = this.sku;
|
476
476
|
retData.globalProductID = this.globalProductID;
|
@@ -505,7 +505,6 @@ const Product = function(productData) {
|
|
505
505
|
retData.pvMap = this.pvMap;
|
506
506
|
retData.orderTypes = this.orderTypes;
|
507
507
|
retData.childSkus = this.childSkus;
|
508
|
-
retData.equinoxChildSkus = this.equinoxChildSkus;
|
509
508
|
retData.custTypes = this.custTypes;
|
510
509
|
retData.division = this.division;
|
511
510
|
retData.backOrderDate = this.backOrderDate;
|
@@ -540,11 +539,11 @@ const Product = function(productData) {
|
|
540
539
|
return retData;
|
541
540
|
};
|
542
541
|
|
543
|
-
this.setMeCommerceProductData = function(/*productData*/) {
|
542
|
+
this.setMeCommerceProductData = function (/*productData*/) {
|
544
543
|
console.error("setMeCommerceProductData is deprecated!");
|
545
544
|
};
|
546
545
|
|
547
|
-
this.setBaseUrl = function(baseUrl) {
|
546
|
+
this.setBaseUrl = function (baseUrl) {
|
548
547
|
this.thumbnail = ProductUtils.applyBaseUrl(this.thumbnail, baseUrl);
|
549
548
|
this.fullImage = ProductUtils.applyBaseUrl(this.fullImage, baseUrl);
|
550
549
|
|
@@ -556,7 +555,7 @@ const Product = function(productData) {
|
|
556
555
|
}
|
557
556
|
};
|
558
557
|
|
559
|
-
this.setProductData = function(productData) {
|
558
|
+
this.setProductData = function (productData) {
|
560
559
|
let data;
|
561
560
|
|
562
561
|
if (productData) {
|
@@ -664,7 +663,7 @@ const Product = function(productData) {
|
|
664
663
|
? data.pvMap
|
665
664
|
: this.pvMap;
|
666
665
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, data.orderTypes);
|
667
|
-
if(data.childSkus) {
|
666
|
+
if (data.childSkus) {
|
668
667
|
this.childSkus = data.childSkus;
|
669
668
|
}
|
670
669
|
this.custTypes = data.custTypes || [];
|
@@ -677,14 +676,10 @@ const Product = function(productData) {
|
|
677
676
|
}
|
678
677
|
|
679
678
|
this.equinoxProductId = data.equinoxProductId;
|
680
|
-
|
681
|
-
if(data.equinoxChildSkus) {
|
682
|
-
this.equinoxChildSkus = data.equinoxChildSkus;
|
683
|
-
}
|
684
679
|
}
|
685
680
|
};
|
686
681
|
|
687
|
-
this.isEmpty = function() {
|
682
|
+
this.isEmpty = function () {
|
688
683
|
return (
|
689
684
|
isFieldEmpty(this.sku) &&
|
690
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'
|
@@ -129,9 +129,15 @@ const ProductData = {
|
|
129
129
|
*/
|
130
130
|
eqProductVariantMapper: function (eqVariant) {
|
131
131
|
|
132
|
-
let imageURL = eqVariant.properties.imageURL
|
133
|
-
|
132
|
+
let imageURL = eqVariant.properties.imageURL;
|
133
|
+
const regex = /\d+\.\d+/
|
134
|
+
let thumbnailImage = ''
|
134
135
|
|
136
|
+
if (imageURL.includes('contentstack')) {
|
137
|
+
thumbnailImage = imageURL + '?width=40'
|
138
|
+
} else {
|
139
|
+
thumbnailImage = imageURL.replace(regex, '40.40')
|
140
|
+
}
|
135
141
|
|
136
142
|
const { eventName, eventLabels, computedPrice, defaultProductPrice, CVPrice, PVPrice } = this.getEqProductPromotions(eqVariant);
|
137
143
|
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
@@ -298,7 +304,8 @@ const ProductData = {
|
|
298
304
|
},
|
299
305
|
"restrictedMarkets": [],
|
300
306
|
"addOns": [],
|
301
|
-
"equinoxProductId": eqVariant.identifier
|
307
|
+
"equinoxProductId": eqVariant.identifier,
|
308
|
+
"variantDefault": eqVariant.default
|
302
309
|
};
|
303
310
|
},
|
304
311
|
|
@@ -351,142 +358,146 @@ const ProductData = {
|
|
351
358
|
}
|
352
359
|
},
|
353
360
|
|
361
|
+
|
354
362
|
eqProductMapper: async function (productDataResponse, skus) {
|
363
|
+
// console.log(productDataResponse, skus);
|
355
364
|
let count = 0;
|
356
|
-
let variants = {};
|
357
365
|
const products = [];
|
358
366
|
|
359
367
|
for (const productData of productDataResponse) {
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
if (productData.sku && productData.sku.length > 1) {
|
367
|
-
// exclude base product from variants
|
368
|
-
productData.sku.filter(v => v.identifier.substring(2, 4) !== "55").map(variant => {
|
369
|
-
variants[variant.identifier] = this.eqProductVariantMapper(variant);
|
370
|
-
return variant;
|
371
|
-
});
|
372
|
-
}
|
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 = ''
|
373
374
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
defaultProductPrice,
|
379
|
-
CVPrice,
|
380
|
-
PVPrice
|
381
|
-
} = this.getEqProductPromotions(product);
|
382
|
-
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
383
|
-
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
384
|
-
const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
|
385
|
-
const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
|
386
|
-
|
387
|
-
product.equinoxChildSkus = await this.fetchChildSkus(product);
|
388
|
-
product.availableQuantity = mapAvailableQuantity(product);
|
389
|
-
product = {
|
390
|
-
...product,
|
391
|
-
"sku": product.identifier,
|
392
|
-
"globalProductID": productData.identifier,
|
393
|
-
"title": productData.properties.name,
|
394
|
-
"country": product.properties.market,
|
395
|
-
"language": "en",
|
396
|
-
"shortDescr": productData.properties.description,
|
397
|
-
"longDescr": productData.properties.productDetailsDescription,
|
398
|
-
"fullImage": imageURL,
|
399
|
-
"imageAltText": productData.properties.name,
|
400
|
-
"productCarouselImages": [
|
401
|
-
{
|
402
|
-
"contentType": "img",
|
403
|
-
"src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
|
404
|
-
"alt": ""
|
405
|
-
}
|
406
|
-
],
|
407
|
-
"thumbnail": thumbnailImage,
|
408
|
-
"ingredients": productData.properties.ingredients,
|
409
|
-
"benefits": productData.properties.benefits,
|
410
|
-
"usage": productData.properties.usage,
|
411
|
-
"resources": product.properties.resources,
|
412
|
-
"videos": "",
|
413
|
-
"movie": "",
|
414
|
-
"youtube": "",
|
415
|
-
"salesEventText": "",
|
416
|
-
"contentSection": [
|
417
|
-
{
|
418
|
-
"sectionContent": "<div class=\"contentSections\"></div>\n"
|
419
|
-
}
|
420
|
-
],
|
421
|
-
"scanQualified": productData.properties.scanQualifiedCount,
|
422
|
-
"maxQuantity": 999,
|
423
|
-
"points": "",
|
424
|
-
"cv": productCVPrice,
|
425
|
-
"pv": productPVPrice,
|
426
|
-
"priceType": "WRTL",
|
427
|
-
"price": discountedPrice,
|
428
|
-
"priceMap": {
|
429
|
-
"WRTL": productPrice,
|
430
|
-
"WADW-WRTL": product.priceFacets["Regular Price"],
|
431
|
-
"WADR": product.priceFacets["Regular Price"],
|
432
|
-
"RTL": product.priceFacets["Regular Price"],
|
433
|
-
"WADW": product.priceFacets["Wholesale Price"],
|
434
|
-
"WHL": product.priceFacets["Wholesale Price"],
|
435
|
-
"WWHL": product.priceFacets["Wholesale Price"]
|
436
|
-
},
|
437
|
-
"cvMap": {
|
438
|
-
"WWHL": productCVPrice,
|
439
|
-
"WADW": productCVPrice,
|
440
|
-
"WHL": productCVPrice
|
441
|
-
},
|
442
|
-
"pvMap": {
|
443
|
-
"WWHL": productPVPrice,
|
444
|
-
"WADW": productPVPrice,
|
445
|
-
"WHL": productPVPrice
|
446
|
-
},
|
447
|
-
"orderTypes": this._setOrderType(product.properties),
|
448
|
-
"childSkus": [],
|
449
|
-
"custTypes": this.switchCustType(product.properties.customerTypes),
|
450
|
-
"division": productData.properties.division,
|
451
|
-
"backOrderDate": null,
|
452
|
-
"locallyProduced": false,
|
453
|
-
"agelocme": null,
|
454
|
-
"count": "",
|
455
|
-
"flavor": "",
|
456
|
-
"size": product.properties.size,
|
457
|
-
"shade": "",
|
458
|
-
"status": this.switchStatusFromEquinox(product.properties.productStatus),
|
459
|
-
"variantType": "Other",
|
460
|
-
"variantDropdownLabel": product.properties.variantLabel || "",
|
461
|
-
"variantDropdownPlaceholder": "Select Type",
|
462
|
-
"variantsLabel": product.properties.variantLabel || "",
|
463
|
-
"groupOffer": false,
|
464
|
-
"personalOffer": false,
|
465
|
-
"savedEventName": eventName,
|
466
|
-
"salesLabel": eventLabels,
|
467
|
-
"eventName": eventName,
|
468
|
-
"sizeWeight": '',
|
469
|
-
"nettoWeight": "",
|
470
|
-
"variants": variants,
|
471
|
-
"searchScore": 0,
|
472
|
-
"isExclusive": product.properties.isExclusive || false,
|
473
|
-
"marketAttributes": {
|
474
|
-
"discount": true,
|
475
|
-
"redeem": true,
|
476
|
-
"earn": true
|
477
|
-
},
|
478
|
-
"restrictedMarkets": [],
|
479
|
-
"addOns": [],
|
480
|
-
"inventory": product.inventory || "", //inventory label
|
481
|
-
"equinoxProductId": productData.identifier
|
482
|
-
};
|
483
|
-
|
484
|
-
products.push(new Product(product));
|
485
|
-
} catch (err) {
|
486
|
-
console.error('Unable to map the product', productData.identifier, ':', err);
|
487
|
-
console.error('Product info:', productDataResponse, skus);
|
488
|
-
continue;
|
375
|
+
if (imageURL.includes('contentstack')) {
|
376
|
+
thumbnailImage = imageURL + '?width=40'
|
377
|
+
} else {
|
378
|
+
thumbnailImage = imageURL.replace(regex, '40.40')
|
489
379
|
}
|
380
|
+
|
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
|
+
});
|
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));
|
490
501
|
}
|
491
502
|
|
492
503
|
let data = {
|
@@ -529,7 +540,7 @@ const ProductData = {
|
|
529
540
|
type: 'SKUKIT',
|
530
541
|
availableChannels: product.properties.availableChannels
|
531
542
|
},
|
532
|
-
...res.data.product.map(p =>
|
543
|
+
...res.data.product.map(p => this.buildChildSkus(kits, p))
|
533
544
|
];
|
534
545
|
|
535
546
|
return childSkus;
|
@@ -538,6 +549,23 @@ const ProductData = {
|
|
538
549
|
return [];
|
539
550
|
},
|
540
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
|
+
|
541
569
|
/**
|
542
570
|
*
|
543
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;
|