@nuskin/ns-product-lib 2.13.0-cx24-5107.13 → 2.13.0-cx24-5107.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,10 @@
1
+ # [2.13.0-cx24-5107.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.13.0-cx24-5107.13...v2.13.0-cx24-5107.14) (2023-10-19)
2
+
3
+
4
+ ### New
5
+
6
+ * Handle adding variants from bundle ([bce1628](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bce1628f5e6b1bec99d37da1481a3e53fe7f7a1e))
7
+
1
8
  # [2.13.0-cx24-5107.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.13.0-cx24-5107.12...v2.13.0-cx24-5107.13) (2023-10-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.13.0-cx24-5107.13",
3
+ "version": "2.13.0-cx24-5107.14",
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": {
@@ -7,9 +7,27 @@ const mapBackOrderDate = require('./backOrderDate');
7
7
  * @param {import('.').EquinoxNormalProduct} product
8
8
  */
9
9
  function childSKUBundle(kits, product) {
10
- const sku = product.sku.filter(sku => sku.default)[0];
10
+ let sku;
11
+ let personalOffer = JSON.parse(sessionStorage.getItem('personalOffer'))
12
+ if (personalOffer.active) {
13
+ //get the products with variants selected
14
+ const productWithVariant = personalOffer.products.filter((sku) => sku.variantSelected !== null)[0]
15
+ if (productWithVariant !== null) {
16
+ sku = product.sku.filter((sku) => {
17
+ console.log('Checking sku ' + sku.identifier + ` ` + product.identifier)
18
+ return sku.identifier === productWithVariant.variantSelected[product.identifier]
19
+ })[0]
20
+ }
21
+ if (!sku) {
22
+ sku = product.sku.filter(sku => sku.default)[0];
23
+ }
24
+ } else {
25
+ sku = product.sku.filter(sku => sku.default)[0];
26
+ }
27
+
28
+
11
29
  if (!sku) {
12
- throw Error('Unable to find the default SKU.');
30
+ throw Error('Unable to find the default SKU for product ' + product.identifier);
13
31
  }
14
32
 
15
33
  const kit = kits.filter(k => k.sku === product.identifier)[0];
@@ -31,4 +49,5 @@ function childSKUBundle(kits, product) {
31
49
  }
32
50
  }
33
51
 
52
+
34
53
  module.exports = childSKUBundle;