{{-- resources/views/storefront/cart.blade.php --}} @extends('storefront.layout') @section('title', trans_key('storefront.pageTitles.cart').' - '.config('app.name', 'FreshMart')) @section('body_class', 'sf-app-cart-body') @section('content') @php $items = $cart?->items ?? collect(); $summary = $summary ?? []; $subtotal = (float) data_get($summary, 'subtotal', 0); $discount = (float) data_get($summary, 'discount_total', data_get($summary, 'coupon_discount_total', 0)); $couponDiscount = (float) data_get($summary, 'coupon_discount_total', 0); $comboDiscount = (float) data_get($summary, 'combo_discount_total', 0); $deliveryFee = (float) data_get($summary, 'delivery_fee', 0); $platformFee = (float) data_get($summary, 'platform_fee', 0); $taxTotal = (float) data_get($summary, 'tax_total', 0); $payableAmount = (float) data_get($summary, 'payable_amount', $cartTotal ?? 0); $itemQuantity = (int) $items->sum('quantity'); $isGrocery = ($selectedService ?? 'grocery') !== 'food'; $freeDeliveryRemaining = $freeDeliveryThreshold !== null ? max(0, (float) $freeDeliveryThreshold - (float) ($cartTotal ?? $subtotal)) : null; $freeDeliveryProgress = $freeDeliveryThreshold ? min(100, max(8, (((float) ($cartTotal ?? $subtotal)) / max(1, (float) $freeDeliveryThreshold)) * 100)) : 0; $storeLogo = $cart?->store ? \App\Support\StorefrontPresenter::storeLogo($cart->store) : null; @endphp
{{ $isGrocery ? 'Cart' : 'Your Cart' }} @if($items->count())
@csrf @method('DELETE')
@else @endif
@if($items->count())

{{ $cart?->store?->name ?? trans_key('storefront.fallbacks.store') }}

{{ $itemQuantity }} item{{ $itemQuantity === 1 ? '' : 's' }} in cart

@if($cart?->store?->is_open) Open and accepting orders @endif
Add items
📍
Delivery address

{{ session('delivery_location', 'Select delivery location') }}

@if($freeDeliveryThreshold !== null)
{{ $freeDeliveryRemaining <= 0 ? '🎉 You unlocked free delivery!' : 'Add '.\App\Support\StorefrontPresenter::money($freeDeliveryRemaining).' more for free delivery' }}
@endif
@foreach($items as $item) @php $product = $item->product; $image = $product ? \App\Support\StorefrontPresenter::productImage($product) : null; $unitPrice = (float) ($item->unit_price ?? 0); $lineTotal = (float) ($item->line_total ?? ($unitPrice * $item->quantity)); @endphp
@if($image) {{ $product?->name }} @else {{ \Illuminate\Support\Str::upper(\Illuminate\Support\Str::substr($product?->name ?? 'I', 0, 1)) }} @endif

{{ $product?->name ?? trans_key('storefront.fallbacks.productUnavailable') }}

{{ $item->productVariant?->name ?: 'Regular' }}

{{ \App\Support\StorefrontPresenter::money($unitPrice) }} {{ \App\Support\StorefrontPresenter::money($lineTotal) }}
@if((int) $item->quantity > 1)
@csrf @method('PUT')
@else
@csrf @method('DELETE')
@endif {{ (int) $item->quantity }}
@csrf @method('PUT')
@csrf @method('DELETE')
@endforeach

Bill Details

Item total
{{ \App\Support\StorefrontPresenter::money($subtotal) }}
@if($comboDiscount > 0)
Bundle savings
-{{ \App\Support\StorefrontPresenter::money($comboDiscount) }}
@endif @if($couponDiscount > 0)
Coupon savings
-{{ \App\Support\StorefrontPresenter::money($couponDiscount) }}
@endif @if($discount > 0 && $comboDiscount <= 0 && $couponDiscount <= 0)
Discount
-{{ \App\Support\StorefrontPresenter::money($discount) }}
@endif
Delivery fee
{{ $deliveryFee > 0 ? \App\Support\StorefrontPresenter::money($deliveryFee) : 'FREE' }}
@if($platformFee > 0)
Platform fee
{{ \App\Support\StorefrontPresenter::money($platformFee) }}
@endif @if($taxTotal > 0)
Taxes
{{ \App\Support\StorefrontPresenter::money($taxTotal) }}
@endif
To pay
{{ \App\Support\StorefrontPresenter::money($payableAmount) }}
@if(($availableCoupons ?? collect())->count()) @endif
{{ \App\Support\StorefrontPresenter::money($payableAmount) }} {{ $itemQuantity }} item{{ $itemQuantity === 1 ? '' : 's' }} {{ $isGrocery ? 'Confirm cart' : 'Proceed to checkout' }}
@else

Your cart is empty

Add your favourite items and come back here to confirm cart.

Start shopping
@endif
@endsection