@nuskin/ns-product-lib 2.6.0-cx24-3464.12 → 2.6.0-cx24-3464.13
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# [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)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* 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)
|
7
|
+
* 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)
|
8
|
+
|
1
9
|
# [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
10
|
|
3
11
|
|
package/package.json
CHANGED
@@ -0,0 +1,19 @@
|
|
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.map(cs => cs.inventory.atpQty);
|
13
|
+
return Math.min(...quantities);
|
14
|
+
}
|
15
|
+
|
16
|
+
return 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
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
|
+
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 { availableQuantity } = require('./equinox-helpers');
|
8
9
|
|
9
10
|
const productTypes = {
|
10
11
|
kit: 'kit'
|
@@ -409,7 +410,7 @@ const ProductData = {
|
|
409
410
|
}
|
410
411
|
],
|
411
412
|
"scanQualified": productData.properties.scanQualifiedCount,
|
412
|
-
"availableQuantity": (product
|
413
|
+
"availableQuantity": availableQuantity(product),
|
413
414
|
"maxQuantity": 999,
|
414
415
|
"points": "",
|
415
416
|
"cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
|