@nuskin/cs-product-lib 1.0.19 → 1.0.20-cx12-7271.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/csProduct.js +20 -65
package/package.json
CHANGED
package/src/csProduct.js
CHANGED
|
@@ -344,75 +344,30 @@ const csProduct = (props) => {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
const getBundle = async (id, locale) => {
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
query,
|
|
350
|
-
locale,
|
|
351
|
-
contentType: BUNDLE_TYPE
|
|
352
|
-
})
|
|
353
|
-
const translations = await getTranslations(locale)
|
|
354
|
-
|
|
355
|
-
for (let b = 0; b < bundles.length; b++) {
|
|
356
|
-
for (
|
|
357
|
-
let i = 0;
|
|
358
|
-
i < (bundles[b].required_products || []).length;
|
|
359
|
-
i++
|
|
360
|
-
) {
|
|
361
|
-
await removeInvalidVariants(
|
|
362
|
-
bundles[b].required_products[i].product,
|
|
363
|
-
locale,
|
|
364
|
-
translations
|
|
365
|
-
)
|
|
366
|
-
}
|
|
367
|
-
for (
|
|
368
|
-
let i = 0;
|
|
369
|
-
i < (bundles[b].optional_products || []).length;
|
|
370
|
-
i++
|
|
371
|
-
) {
|
|
372
|
-
await removeInvalidVariants(
|
|
373
|
-
bundles[b].optional_products[i].product,
|
|
374
|
-
locale,
|
|
375
|
-
translations
|
|
376
|
-
)
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return formatKitWithSchema(bundles)?.[0]
|
|
347
|
+
const bundles = await getBundles(id, locale)
|
|
348
|
+
return bundles && bundles[0] ? bundles[0] : null
|
|
380
349
|
}
|
|
381
350
|
|
|
382
351
|
const getBundles = async (ids, locale) => {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
)
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
)
|
|
402
|
-
}
|
|
403
|
-
for (
|
|
404
|
-
let i = 0;
|
|
405
|
-
i < (bundles[b].optional_products || []).length;
|
|
406
|
-
i++
|
|
407
|
-
) {
|
|
408
|
-
await removeInvalidVariants(
|
|
409
|
-
bundles[b].optional_products[i].product,
|
|
410
|
-
locale,
|
|
411
|
-
translations
|
|
412
|
-
)
|
|
413
|
-
}
|
|
352
|
+
if (!Array.isArray(ids)) {
|
|
353
|
+
ids = [ids]
|
|
354
|
+
}
|
|
355
|
+
const idString = helpers?.arrayString([ids])
|
|
356
|
+
const query = `{"$or": [
|
|
357
|
+
{"product_bundle":{"$in_query":{"bundle_id":{"$in": ${idString}}}}},
|
|
358
|
+
{"product_bundle":{"$in_query":{"uid":{"$in": ${idString}}}}},
|
|
359
|
+
{"sku_kit":{"$in_query":{"kit_id":{"$in": ${idString}}}}},
|
|
360
|
+
{"sku_kit":{"$in_query":{"uid":{"$in": ${idString}}}}}
|
|
361
|
+
]}`
|
|
362
|
+
const products = await queryProducts(query, locale)
|
|
363
|
+
if (products.length > 0) {
|
|
364
|
+
const translations = await getTranslations(locale)
|
|
365
|
+
await formatKit(products, locale, translations)
|
|
366
|
+
await removeInvalidVariants(products, locale, translations)
|
|
367
|
+
return formatProductWithSchema(products)
|
|
368
|
+
} else {
|
|
369
|
+
return []
|
|
414
370
|
}
|
|
415
|
-
return formatKitWithSchema(bundles)
|
|
416
371
|
}
|
|
417
372
|
|
|
418
373
|
const getProductsBySku = async (skus, locale) => {
|