@php $colors = $product->variants->pluck('color')->filter()->unique()->values(); $sizes = $product->variants->pluck('size')->filter()->unique()->values(); $inStock = $product->variants->contains(fn ($v) => $v->stock_status !== 'out_of_stock'); $defaultVariant = $product->variants->first(fn ($v) => $v->stock_status !== 'out_of_stock') ?? $product->variants->first(); // The default-selected swatches must match $defaultVariant (preferring // an in-stock variant), not just "first in the list" — otherwise the // page can load with Add to Cart already disabled because the first // color/size combo happens to be out of stock while others aren't. $defaultColor = $defaultVariant?->color ?? $colors->first(); $defaultSize = $defaultVariant?->size ?? $sizes->first(); $variantOptions = $product->variants->map(fn ($v) => [ 'id' => $v->id, 'color' => $v->color, 'size' => $v->size, 'in_stock' => $v->stock_status !== 'out_of_stock', ])->values(); @endphp
@if (count($product->images ?? []) > 1)
@foreach ($product->images as $image) @endforeach
@endif @if ($product->video_path) @endif

{{ $product->title }}

@if ($inStock) In Stock @else Out of Stock @endif
${{ number_format($product->price, 2) }} @if ($product->compare_at_price && $product->compare_at_price > $product->price) @php $percentOff = round((1 - $product->price / $product->compare_at_price) * 100); @endphp ${{ number_format($product->compare_at_price, 2) }} {{ $percentOff }}% OFF @endif
@csrf @if ($colors->isNotEmpty())
Color
@foreach ($colors as $color) @php $cssColor = \App\Services\Html\ColorSwatch::resolve($color); @endphp @if ($cssColor) @else {{-- Not a real CSS color (e.g. a finish like "Glossy", or a compound name like "Rose Gold") — a colored dot would render invisible, so show the name as a text pill instead. --}} {{ $color }} @endif @endforeach
@endif @if ($sizes->isNotEmpty())
@endif
Fast & reliable delivery across USA
Secure checkout via Stripe
Free cancellation within 2 hours of order placement
@if ($product->description)

Description

{!! $product->description !!}
@endif @if ($related->isNotEmpty())

You May Also Like

@foreach ($related as $relatedProduct)
@endforeach
@endif