fix(storefront): Show kit contents and pick variations on product page - #799
Open
vitorrgg wants to merge 2 commits into
Open
fix(storefront): Show kit contents and pick variations on product page#799vitorrgg wants to merge 2 commits into
vitorrgg wants to merge 2 commits into
Conversation
Kit products (`kit_composition`) were rendered like plain products: the composition was never listed and kit items with variations went to cart without a selected SKU. - `use-product-details`: expose `isKit`, `kitComposition` and `selectKitVariation`, load kit items on mount and require a variation per composition slot before buying; shipping is now calculated with the kit items instead of the (weightless) kit product - `use-product-card`: fetch `variations` for kit items, honor a fixed `kit_composition[].variation_id`, cap kit quantity by the least available item (was taking the max) and set `kit_product` before adding to cart, otherwise a matching standalone item on cart was merged into the kit - new `KitComposition.vue` shared component listing each item with picture, link and quantity, with a `variations` slot for theme SKU selectors Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Splits the kit branch into `matchKitItem`, `sumToKitComposition` and `parseKitCartItems`, dropping `loadToCart` back under the complexity threshold flagged by CodeFactor. No behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
Produtos do tipo kit (com
kit_composition) eram renderizados na seção de detalhes como um produto comum: a composição nunca era listada e, quando os itens do kit tinham variações, eles iam para o carrinho sem SKU selecionado.Exemplo real (loja demo 1011,
DEMO-NICHO-kit-camisaria-masculina): três camisas, cada uma comhas_variations: truee 5 tamanhos — não havia como escolher o tamanho de cada peça.Junto com isso, a camada de dados tinha três defeitos:
loadKitItemspegava o maiorfloor(estoque / qnt)entre os itens em vez do menor, liberando mais kits do que os componentes permitem.kit_productera gravado depois doaddCartItem, então um componente já presente no carrinho era mesclado e passava a ser tratado como item de kit.Mudanças
use-product-card.tskitItemFieldspassa a trazervariations,visible,base_priceemin_quantityloadKitItemsdeduplica IDs, é idempotente e usa o mínimo entre os itens, respeitandokit_composition[].variation_idfixoloadToCartaceitakitVariationIds, valida SKU e estoque item a item, agrupa produtos repetidos na composição e montakit_product(comvariation_idemcomposition) antes de inserir no carrinhouse-product-details.tsisKit,kitComposition,selectKitVariationeisLoadingKitItemsonMountedisSkuSelectedpassa a exigir variação escolhida em cada slot do kit, reaproveitando o alerta já existenteshippedItemspassa a ser a composição real do kitKitComposition.vue(novo, em@@sf/components)variationspara o tema injetar seu próprio seletor de SKU, com<select>como fallbackTema
A renderização em si exige uma alteração correspondente em
ecomplus/store(functions/ssr/src/components/ProductDetails.vue): incluir o<KitComposition>passando oSkuSelectordo tema no slot, esconder o "Comprar agora" direto em kits (o link porproduct_idnão explode a composição) e usari19buyKitno CTA. Vai em PR separado.Verificação
tsc --noEmite ESLint limpos nos arquivos alterados/kit-camisaria-tres-basicasresponde 200 com o bloco da composição renderizado, e uma página não-kit segue idênticaspecificationsde cada componenteNão deu para exercitar o clique/hidratação (escolher tamanho → adicionar ao carrinho) sem navegador — vale um teste manual antes do merge.
🤖 Generated with Claude Code