stock check, variants in cart, variant buttons in product page

This commit is contained in:
elvira
2026-09-17 21:52:39 +03:00
parent fe55cb5f33
commit afa1993c53
27 changed files with 564 additions and 155 deletions
+14 -1
View File
@@ -17,6 +17,9 @@
class="grid grid-cols-1 md:grid-cols-2 gap-12"
data-controller="product-form"
data-product-form-variants-value="{{ json_encode($variantsData) }}"
data-product-form-stock-check-url-value="{{ route('product.stock-check', app()->getLocale()) }}"
data-product-form-stock-error-one-value="{{ trans_choice('storefront.product.add_to_cart_failed', 1) }}"
data-product-form-stock-error-many-value="{{ trans_choice('storefront.product.add_to_cart_failed', 2, ['count' => ':count']) }}"
>
{{-- Image --}}
@@ -167,7 +170,11 @@ class="absolute bottom-6 right-8 text-white text-sm"
</div>
@if($option && !empty($product['variants']))
<x-ui.color-swatch :variants="$product['variants']" :option="$option" />
@if($optionIsColor)
<x-ui.color-swatch :variants="$product['variants']" :option="$option" />
@else
<x-ui.option-buttons :variants="$product['variants']" :option="$option" />
@endif
@endif
<x-checkout::add-to-cart
@@ -179,6 +186,12 @@ class="flex items-stretch gap-10"
<x-ui.button type="submit" class="flex-1">{{ __('storefront.product.add_to_cart') }}</x-ui.button>
</x-checkout::add-to-cart>
{{-- Storefront-owned, not part of the checkout module — the
local stock pre-check in product-form-controller.js stops
an over-limit submit before it ever reaches the module
and reports it here. --}}
<p class="text-sm text-red-600" data-product-form-target="stockError" hidden role="alert"></p>
</div>
</div>