@nuskin/ns-product-lib 2.6.0-cx24-3464.12 → 2.6.0-cx24-3464.14
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# [2.6.0-cx24-3464.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3464.13...v2.6.0-cx24-3464.14) (2023-03-11)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* get child skus to be used for add-to-cart #CX24-3464 ([2ca95d0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2ca95d0a0f4280ad01d5a39673806d307b185c5b)), closes [#CX24-3464](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3464)
|
7
|
+
|
8
|
+
# [2.6.0-cx24-3464.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3464.12...v2.6.0-cx24-3464.13) (2023-03-11)
|
9
|
+
|
10
|
+
|
11
|
+
### Update
|
12
|
+
|
13
|
+
* get child skus to be used for add-to-cart #CX24-3464 ([b865b9d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b865b9d4705d2958093ccf7f2156e7ccfb0a3efb)), closes [#CX24-3464](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3464)
|
14
|
+
* get child skus to be used for add-to-cart #CX24-3464 ([8ccde01](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8ccde019f07af4dbeeae312fc31d2b3130f54334)), closes [#CX24-3464](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3464)
|
15
|
+
|
1
16
|
# [2.6.0-cx24-3464.12](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0-cx24-3464.11...v2.6.0-cx24-3464.12) (2023-03-11)
|
2
17
|
|
3
18
|
|
package/package.json
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* mapAvailableQuantity returns the atp (available-to-purchase) quantity.
|
3
|
+
* @param {import('./').Product} product
|
4
|
+
* @returns {number}
|
5
|
+
*/
|
6
|
+
function mapAvailableQuantity(product) {
|
7
|
+
if (product.inventoryProperties) {
|
8
|
+
return product.inventoryProperties.atpQty;
|
9
|
+
}
|
10
|
+
|
11
|
+
if (product.childSkus && product.childSkus.length > 0) {
|
12
|
+
const quantities = product.childSkus
|
13
|
+
.filter(cs => cs.inventory !== undefined)
|
14
|
+
.map(cs => cs.inventory.atpQty);
|
15
|
+
|
16
|
+
return Math.min(...quantities);
|
17
|
+
}
|
18
|
+
|
19
|
+
return 0;
|
20
|
+
}
|
21
|
+
|
22
|
+
module.exports = mapAvailableQuantity;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef Product
|
3
|
+
* @type {object}
|
4
|
+
* @property {ChildSku[]} childSkus
|
5
|
+
* @property {Inventory} [inventoryProperties]
|
6
|
+
*
|
7
|
+
* @typedef ChildSku
|
8
|
+
* @type {object}
|
9
|
+
* @property {string} productId
|
10
|
+
* @property {string} skuId
|
11
|
+
* @property {string} type
|
12
|
+
* @property {number} skuQuantity
|
13
|
+
* @property {string} availableChannels
|
14
|
+
* @property {Inventory} [inventory]
|
15
|
+
*
|
16
|
+
* @typedef Inventory
|
17
|
+
* @type {object}
|
18
|
+
* @property {number} atpQty
|
19
|
+
* @property {boolean} backOrdered
|
20
|
+
*/
|
21
|
+
const availableQuantity = require('./availableQuantity');
|
22
|
+
|
23
|
+
module.exports = {
|
24
|
+
mapAvailableQuantity: availableQuantity
|
25
|
+
};
|
package/src/productData.js
CHANGED
@@ -5,6 +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 } = require('./equinox-helpers');
|
8
9
|
|
9
10
|
const productTypes = {
|
10
11
|
kit: 'kit'
|
@@ -377,7 +378,10 @@ const ProductData = {
|
|
377
378
|
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
378
379
|
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
379
380
|
|
381
|
+
product.childSkus = await this.fetchChildSkus(product);
|
382
|
+
product.availableQuantity = mapAvailableQuantity(product);
|
380
383
|
product = {
|
384
|
+
...product,
|
381
385
|
"sku": product.identifier,
|
382
386
|
"globalProductID": productData.identifier,
|
383
387
|
"title": productData.properties.name,
|
@@ -409,7 +413,6 @@ const ProductData = {
|
|
409
413
|
}
|
410
414
|
],
|
411
415
|
"scanQualified": productData.properties.scanQualifiedCount,
|
412
|
-
"availableQuantity": (product.inventoryProperties) ? product.inventoryProperties.atpQty : 0,
|
413
416
|
"maxQuantity": 999,
|
414
417
|
"points": "",
|
415
418
|
"cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|
@@ -436,7 +439,6 @@ const ProductData = {
|
|
436
439
|
"WHL": product.priceFacets.PV
|
437
440
|
},
|
438
441
|
"orderTypes": this._setOrderType(product.properties),
|
439
|
-
childSkus: await this.fetchChildSkus(product),
|
440
442
|
"custTypes": this.switchCustType(product.properties.customerTypes),
|
441
443
|
"division": productData.properties.division,
|
442
444
|
"backOrderDate": null,
|