@decocms/apps-vtex 7.34.4 → 7.36.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/apps-vtex",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.36.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco commerce app: VTEX integration",
|
|
6
6
|
"repository": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"lint:unused": "knip"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@decocms/blocks": "7.
|
|
55
|
-
"@decocms/apps-commerce": "7.
|
|
56
|
-
"@decocms/apps-website": "7.
|
|
57
|
-
"@decocms/tanstack": "7.
|
|
54
|
+
"@decocms/blocks": "7.36.0",
|
|
55
|
+
"@decocms/apps-commerce": "7.36.0",
|
|
56
|
+
"@decocms/apps-website": "7.36.0",
|
|
57
|
+
"@decocms/tanstack": "7.36.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@tanstack/react-query": ">=5.0.0",
|
|
@@ -13,6 +13,12 @@ import type { Product as ProductVTEX } from "../../utils/types";
|
|
|
13
13
|
|
|
14
14
|
export interface ProductListProps {
|
|
15
15
|
props?: CollectionProps | QueryProps | ProductIDProps | FacetsProps;
|
|
16
|
+
/**
|
|
17
|
+
* Include every SKU as a lean variant in each product's isVariantOf.hasVariant[]
|
|
18
|
+
* so shelf cards can render the full size/color grid. Default false (lean shelf:
|
|
19
|
+
* a single in-stock variant per product).
|
|
20
|
+
*/
|
|
21
|
+
completeVariants?: boolean;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
interface CollectionProps {
|
|
@@ -139,7 +145,11 @@ export default async function vtexProductListShelf(
|
|
|
139
145
|
const preferredSku = fetchedSkus
|
|
140
146
|
? (p.items.find((item) => fetchedSkus.has(item.itemId)) ?? pickSku(p))
|
|
141
147
|
: pickSku(p);
|
|
142
|
-
return toProductShelf(p, preferredSku, 0, {
|
|
148
|
+
return toProductShelf(p, preferredSku, 0, {
|
|
149
|
+
baseUrl,
|
|
150
|
+
priceCurrency: "BRL",
|
|
151
|
+
shelfCompleteVariants: props.completeVariants,
|
|
152
|
+
});
|
|
143
153
|
});
|
|
144
154
|
|
|
145
155
|
if (ids) {
|
package/src/utils/transform.ts
CHANGED
|
@@ -113,6 +113,13 @@ interface ProductOptions {
|
|
|
113
113
|
variantIncludeImage?: boolean;
|
|
114
114
|
/** When leanVariants is true, still include inventoryLevel on each variant offer. Default true. */
|
|
115
115
|
variantIncludeInventory?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Shelf: include every SKU as a lean variant in isVariantOf.hasVariant[] (via
|
|
118
|
+
* toProductVariant) instead of a single in-stock one. Lets shelf cards render
|
|
119
|
+
* the full size/color grid without pulling the heavy toProduct payload.
|
|
120
|
+
* Default false — preserves the lean single-variant shelf other sites rely on.
|
|
121
|
+
*/
|
|
122
|
+
shelfCompleteVariants?: boolean;
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
/** Returns first available sku */
|
|
@@ -649,11 +656,19 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
|
|
|
649
656
|
level < 1
|
|
650
657
|
? (() => {
|
|
651
658
|
const inStockSku = findFirstAvailable(items) ?? items[0];
|
|
652
|
-
|
|
659
|
+
// Opt-in: every SKU as a lean variant (size/color grid on shelf cards).
|
|
660
|
+
// Default: a single in-stock variant (lean shelf payload).
|
|
661
|
+
const hasVariant = options.shelfCompleteVariants
|
|
662
|
+
? items.map((variantSku) =>
|
|
663
|
+
toProductVariant(product, variantSku, options),
|
|
664
|
+
)
|
|
665
|
+
: inStockSku
|
|
666
|
+
? [toProductShelf(product, inStockSku, 1, options)]
|
|
667
|
+
: [];
|
|
653
668
|
return {
|
|
654
669
|
"@type": "ProductGroup" as const,
|
|
655
670
|
productGroupID: productId,
|
|
656
|
-
hasVariant
|
|
671
|
+
hasVariant,
|
|
657
672
|
url: getProductGroupURL(baseUrl, product).href,
|
|
658
673
|
name: product.productName,
|
|
659
674
|
// Carry the shelf-safe group specs (incl. "Campanha") so ProductCard
|