Shopping Cart

@php $cartItems = \App\Models\CartItem::with('product.supplier') ->where('user_id', auth()->id()) ->get(); $subtotal = $cartItems->sum(fn($item) => $item->quantity * $item->product->price); $tax = $subtotal * 0.15; $total = $subtotal + $tax; @endphp @if($cartItems->isEmpty())

Your cart is empty

Start Shopping
@else
@foreach($cartItems as $item)
@if($item->product->image_url) {{ $item->product->name }} @else 📦 @endif

{{ $item->product->supplier->company_name }}

{{ $item->product->name }}

R {{ number_format($item->product->price, 2) }}

@csrf @method('PATCH') {{ $item->quantity }}
@csrf @method('DELETE')

R {{ number_format($item->quantity * $item->product->price, 2) }}

@endforeach
@endif
@if($cartItems->isNotEmpty())
Subtotal R {{ number_format($subtotal, 2) }}
VAT (15%) R {{ number_format($tax, 2) }}
Total R {{ number_format($total, 2) }}
@endif