@nuskin/ns-product-lib 2.17.1-cx24-67682.1 → 2.17.1-cx24-67682.3
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/graph-ql/product.js +27 -13
package/package.json
CHANGED
package/src/graph-ql/product.js
CHANGED
@@ -438,27 +438,41 @@ function mapChildSKU(kitBundleProducts) {
|
|
438
438
|
if (!kitBundleProducts || !kitBundleProducts.kitProducts) {
|
439
439
|
return [];
|
440
440
|
}
|
441
|
-
|
442
441
|
return kitBundleProducts.kitProducts.map((kitProduct) => {
|
443
442
|
const { product } = kitProduct;
|
444
|
-
|
445
|
-
|
446
|
-
|
443
|
+
if (product.variants.length > 1) {
|
444
|
+
return product.variants.map((variant) => {
|
445
|
+
return {
|
446
|
+
productId: product.id,
|
447
|
+
skuId: variant.sku,
|
448
|
+
type: 'MANDATORY',
|
449
|
+
skuQuantity: variant.availableQuantity,
|
450
|
+
// eslint-disable-next-line max-len
|
451
|
+
availableChannels: Array.isArray(kitBundleProducts.availableChannels) ? kitBundleProducts.availableChannels.join(',') : kitBundleProducts.availableChannels,
|
452
|
+
inventory: {
|
453
|
+
atpQty: variant.availableQuantity,
|
454
|
+
backOrdered: variant.status.isBackordered,
|
455
|
+
backOrderedQty: variant.availableQuantity
|
456
|
+
}
|
457
|
+
}
|
458
|
+
})
|
459
|
+
} else {
|
460
|
+
const defaultVariant = product.variants[0];
|
461
|
+
return {
|
447
462
|
productId: product.id,
|
448
|
-
skuId:
|
463
|
+
skuId: defaultVariant.sku,
|
449
464
|
type: 'MANDATORY',
|
450
|
-
skuQuantity:
|
451
|
-
// eslint-disable-next-line max-len
|
465
|
+
skuQuantity: kitProduct.quantity,
|
452
466
|
availableChannels: Array.isArray(kitBundleProducts.availableChannels) ? kitBundleProducts.availableChannels.join(',') : kitBundleProducts.availableChannels,
|
453
467
|
inventory: {
|
454
|
-
atpQty:
|
455
|
-
backOrdered:
|
456
|
-
backOrderedQty:
|
468
|
+
atpQty: defaultVariant.availableQuantity,
|
469
|
+
backOrdered: defaultVariant.status.isBackordered,
|
470
|
+
backOrderedQty: defaultVariant.availableQuantity
|
457
471
|
}
|
458
|
-
}
|
472
|
+
}
|
473
|
+
|
459
474
|
}
|
460
|
-
|
461
|
-
});
|
475
|
+
}).flat();
|
462
476
|
}
|
463
477
|
|
464
478
|
/**
|