@php $currentPrice = $product->sale_price ?? $product->price; $originalPrice = $product->price; $hasDiscount = $product->sale_price && $product->sale_price < $product->price; $discountPct = $hasDiscount ? round((($originalPrice - $currentPrice) / $originalPrice) * 100) : 0; $inStock = ($product->stock ?? 0) > 0 || $product->hasActiveVariants(); $thumb = $product->thumbnail; $thumbSrc = $thumb && (str_starts_with($thumb, 'http://') || str_starts_with($thumb, 'https://')) ? $thumb : ($thumb ? asset($thumb) : null); $gridContext = $gridContext ?? 'home'; $gridColClass = \App\Services\ProductItemSettingsService::gridColClass($gridContext); $imageFitClass = \App\Services\ProductItemSettingsService::imageFitClass($gridContext); $showCartIcon = \App\Services\ProductItemSettingsService::showAddToCartIcon(); @endphp
@if($thumbSrc) {{ $product->name }} @else
@endif
@if(!$inStock) Sold out @elseif($hasDiscount) {{ $discountPct }}% OFF @endif
{{ $product->name }}
৳{{ number_format($currentPrice) }} @if($hasDiscount) ৳{{ number_format($originalPrice) }} @endif