@php $variants = $product->variants ->where('is_active', true) ->filter(fn ($variant) => $variant->price !== null) ->map(function ($variant) { $stock = $variant->inventories->sum(fn ($inventory) => max(0, $inventory->quantity_available - $inventory->quantity_reserved)); return ['id' => $variant->id, 'name' => $variant->name, 'sku' => $variant->sku, 'price' => (int) $variant->price, 'stock' => (int) $stock, 'images' => $variant->images->map(fn ($image) => $image->image_url)->values()->all()]; })->values(); $selectedVariant = $variants->first(fn ($variant) => $variant['stock'] > 0) ?? $variants->first(); $stock = (int) $variants->sum('stock'); $outlet = $product->inventories->first()?->outlet ?? $product->tenant->outlet; @endphp
{{ $product->name }}
@foreach(($selectedVariant['images'] ?? []) as $index => $imageUrl) @endforeach
@if($policy['requires_prescription'])WAJIB RESEP@endif

{{ $product->brand ?: $product->manufacturer }}

{{ $product->name }}

Rp{{ number_format($selectedVariant['price'] ?? $product->price, 0, ',', '.') }}

{{ number_format((int) ($product->sales_count ?? 0), 0, ',', '.') }} terjual

@if($variants->isNotEmpty())

Pilih varian

Harga dan stok mengikuti pilihan Anda.

Stok {{ $selectedVariant['stock'] ?? 0 }}
@foreach($variants as $variant) @endforeach
@endif

Deskripsi produk

{{ $product->description }}

@if($product->medicineProfile?->warning_label)

{{ $product->medicineProfile->warning_label }}

@endif
@if($relatedProducts->isNotEmpty())
@foreach($relatedProducts->take(10) as $related)@endforeach
@endif
@if($policy['can_sell_online'])
@auth
@csrf
@else@endauth
@csrf
@endif