@nuskin/ns-product-lib 2.14.1 → 2.14.2-cx24-5934.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.14.1",
3
+ "version": "2.14.2-cx24-5934.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": {
@@ -60,12 +60,16 @@ async function getProduct(id, market, locale, config) {
60
60
  const { data } = await graphQlHttpRequest(payload, config);
61
61
 
62
62
  if (data && data.data && data.data.productById) {
63
+
64
+ //use to get default variant based on requested sku
65
+ config.sku = id;
63
66
  const product = mapProduct(data.data.productById, market, locale, config);
64
67
  productData.products.push(new Product(product));
65
68
  productData.count = productData.products.length;
66
69
  }
67
70
 
68
71
  } catch (e) {
72
+ console.log(`ERROR : `, e)
69
73
  console.log(`Unable to fetch product detail for SKU ${id}`);
70
74
  }
71
75
 
@@ -132,8 +136,10 @@ function mapProduct(product, market, locale, config) {
132
136
  });
133
137
  }
134
138
 
139
+
135
140
  //serves as parent
136
- const defaultVariant = variants[0];
141
+ const defaultVariant = !kitBundleProducts ? product.variants.find(v => v.sku === config.sku) : variants[0];
142
+ // const defaultVariant = variants[0];
137
143
  const productImages = mapProductImages(defaultVariant);
138
144
 
139
145
  const {