@props(['product']) @php $activeVariants = $product->variants->where('is_active', true); $firstVariant = $activeVariants->first(fn ($v) => $v->stock_status !== 'out_of_stock') ?? $activeVariants->first(); $isOutOfStock = $activeVariants->isEmpty() || $activeVariants->every(fn ($v) => $v->stock_status === 'out_of_stock'); $isLowStock = ! $isOutOfStock && $firstVariant?->stock_status === 'low_stock'; $optionCount = $activeVariants->count(); $isWishlisted = ($wishlistedIds ?? collect())->contains($product->id); @endphp
@if ($isOutOfStock) Sold Out @elseif ($product->compare_at_price && $product->compare_at_price > $product->price) @php $percentOff = round((1 - $product->price / $product->compare_at_price) * 100); @endphp {{ $percentOff }}% OFF @endif
@auth
@csrf @if ($isWishlisted) @method('DELETE') @endif
@else @endauth @if (! empty($product->images[0])) {{ $product->title }} @else @endif
{{ $product->title }}
${{ number_format($product->price, 2) }} @if ($product->compare_at_price && $product->compare_at_price > $product->price) ${{ number_format($product->compare_at_price, 2) }} @endif
@if ($isLowStock)
Only a few left
@elseif ($optionCount > 1)
{{ $optionCount }} options available
@endif @if ($firstVariant && ! $isOutOfStock)
@csrf
@else @endif