@nuskin/ns-product-lib 2.14.1 → 2.14.2

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",
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,6 +60,9 @@ 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;
@@ -132,8 +135,9 @@ function mapProduct(product, market, locale, config) {
132
135
  });
133
136
  }
134
137
 
138
+
135
139
  //serves as parent
136
- const defaultVariant = variants[0];
140
+ const defaultVariant = !kitBundleProducts ? product.variants.find(v => v.sku === config.sku) : variants[0];
137
141
  const productImages = mapProductImages(defaultVariant);
138
142
 
139
143
  const {