@props(['product' => null, 'image' => null, 'title' => null, 'price' => null, 'originalPrice' => null, 'hoverImage' => null]) @php $isOutOfStock = false; if ($product) { $image = $product->image ? asset('storage/' . $product->image) : asset('images/placeholder.svg'); $title = $product->name; $slug = $product->slug; $minPrice = $product->min_price; $maxPrice = $product->max_price; $isOutOfStock = $product->isOutOfStock(); $hoverImage = $product->images->skip(1)->first()?->image_path; if ($hoverImage) { $hoverImage = asset('storage/' . $hoverImage); } $hasDiscount = false; $discountMin = null; $discountMax = null; $regularMin = $minPrice; $regularMax = $maxPrice; // Check if variants have discounts $variantsWithDiscounts = $product->variants ? $product->variants->where('discount_price', '>', 0) : collect(); if ($variantsWithDiscounts->count() > 0) { $hasDiscount = true; $discountMin = $variantsWithDiscounts->min('discount_price'); $discountMax = $variantsWithDiscounts->max('discount_price'); $regularMin = $product->variants->min('price'); $regularMax = $product->variants->max('price'); } elseif ($product->discount_price > 0 && $product->discount_price < $product->price) { $hasDiscount = true; $discountMin = $product->discount_price; $discountMax = $product->discount_price; $regularMin = $product->price; $regularMax = $product->price; } } else { $slug = '#'; $minPrice = $price; $maxPrice = $price; // If image is already a full URL (like in welcome.blade.php), don't prepend storage/ $imagePath = $image; if (!str_starts_with($imagePath, 'http') && !str_starts_with($imagePath, 'asset')) { $imagePath = asset('storage/' . $imagePath); } $image = $imagePath; if ($hoverImage) { $hoverImagePath = $hoverImage; if (!str_starts_with($hoverImagePath, 'http') && !str_starts_with($hoverImagePath, 'asset')) { $hoverImagePath = asset('storage/' . $hoverImagePath); } $hoverImage = $hoverImagePath; } } @endphp
@if($isOutOfStock)
{{ __('Out of stock') }}
@endif {{ $title }} @if($hoverImage) {{ $title }} hover @endif
{{-- Fixed 2-line slot: single-line titles stay vertically centered so cards stay even --}}

{{ $title }}

@if(isset($hasDiscount) && $hasDiscount) @if($discountMin == $discountMax) ৳{{ number_format((float)$discountMin) }} @else ৳{{ number_format((float)$discountMin) }} - ৳{{ number_format((float)$discountMax) }} @endif @if($regularMin == $regularMax) ৳{{ number_format((float)$regularMin) }} @else ৳{{ number_format((float)$regularMin) }} - ৳{{ number_format((float)$regularMax) }} @endif @else @if($minPrice == $maxPrice) ৳{{ number_format((float)$minPrice) }} @else ৳{{ number_format((float)$minPrice) }} - ৳{{ number_format((float)$maxPrice) }} @endif @endif
@if($isOutOfStock) {{ __('Out of stock') }} @else {{ __('Order Now') }} @endif