{{-- resources/views/storefront/order.blade.php --}} @extends('storefront.layout') @section('title', trans_key('storefront.pageTitles.trackOrder', ['order' => $order->order_number]).' - '.config('app.name', 'FreshMart')) @push('styles') @endpush @section('content')
{{-- Order Header --}}
Order details

#{{ $order->order_number }}

{{ $order->store?->name ?? trans_key('storefront.fallbacks.yourOrder') }} {{ optional($order->placed_at ?? $order->created_at)->format('d M Y, h:i A') }}
{{ \Illuminate\Support\Str::headline($order->status) }}
@php $closedStatuses = ['delivered', 'completed', 'cancelled', 'canceled', 'refunded']; $canTrack = ! in_array($order->status, $closedStatuses, true); @endphp @if($canTrack) Track order @endif ← Back to orders @if(!$canTrack) Shop again @endif
{{-- Flash Messages --}} @if(session('status'))
✓ {{ session('status') }}
@endif @if($errors->any())
Please review:
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif {{-- Takeaway Closing Warning --}} @if($order->is_takeaway && $order->store_closes_at && in_array($order->status, ['payment_pending','prescription_pending','placed','accepted'], true))
Pickup store closes at {{ $order->store_closes_at->format('D, j M g:i A') }}

Please collect before closing, or reschedule this order.

@csrf @method('PATCH')
@endif {{-- Quantity Approval --}} @php $pendingApproval = $order->orderStores ->map(fn ($storeOrder) => data_get($storeOrder->meta, 'quantity_verification')) ->first(fn ($approval) => data_get($approval, 'customer_approval_status') === 'pending'); $money = fn ($value) => \App\Support\StorefrontPresenter::money($value); @endphp @if($pendingApproval)

Quantity changes need approval

Review the revised quantities from the seller.

{{ $money(data_get($pendingApproval, 'original_total', 0)) }} Original total
{{ $money(data_get($pendingApproval, 'revised_total', 0)) }} Revised total
{{ $money(data_get($pendingApproval, 'refund_amount', 0)) }} Refund amount
@csrf
@csrf
@endif {{-- Prescription --}} @php $requiresPrescription = $order->status === 'prescription_pending' || $order->prescriptions->isNotEmpty(); @endphp @if($requiresPrescription)

Prescription

{{ $order->prescriptions->count() }} uploaded

@if($order->prescriptions->isNotEmpty()) @foreach($order->prescriptions as $prescription)
{{ \Illuminate\Support\Str::upper(\Illuminate\Support\Str::substr($prescription->original_name ?: 'RX', 0, 1)) }}

{{ $prescription->original_name ?: 'Prescription' }}

{{ \Illuminate\Support\Str::headline($prescription->status) }}

@if($prescription->notes) {{ $prescription->notes }} @endif
@endforeach @endif @if($order->status === 'prescription_pending')
@csrf
@endif
@endif {{-- Two Column Layout --}}
{{-- Items --}}

Items

{{ $displayItems->count() }} ordered items

@foreach($displayItems as $item) @php $image = $item->product ? \App\Support\StorefrontPresenter::productImage($item->product) : null; $verification = data_get($item->meta, 'quantity_verification'); $displayQuantity = data_get($verification, 'available_quantity', $item->quantity); @endphp
@if($image) {{ $item->product?->name }} @else {{ \Illuminate\Support\Str::upper(\Illuminate\Support\Str::substr($item->product?->name ?? 'I', 0, 1)) }} @endif

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

Qty {{ rtrim(rtrim(number_format((float) $displayQuantity, 2), '0'), '.') }} @if($verification) Verified @endif

{{ $money($item->line_total) }}
@endforeach
{{-- Bill Summary --}}

Bill summary

{{ \Illuminate\Support\Str::headline($order->payment_status ?? 'payment') }}

Subtotal
{{ $money($order->subtotal) }}
@if((float) $order->discount_total > 0)
Discount
-{{ $money($order->discount_total) }}
@endif @if((float) $order->delivery_fee > 0)
Delivery
{{ $money($order->delivery_fee) }}
@endif @if((float) $order->tax_total > 0)
Tax
{{ $money($order->tax_total) }}
@endif @if((float) $order->wallet_amount > 0)
Wallet used
-{{ $money($order->wallet_amount) }}
@endif
Total
{{ $money($order->grand_total) }}
@if($order->delivery_otp && $canTrack)
Delivery OTP

{{ $order->delivery_otp }}

@endif
{{-- Store-wise Status --}} @if($order->orderStores->isNotEmpty())

Store-wise status

{{ $order->orderStores->count() }} sub-orders

@foreach($order->orderStores as $storeOrder)
{{ $storeOrder->pickup_sequence ?: $loop->iteration }}

{{ $storeOrder->store?->name ?? $storeOrder->sub_order_number }}

{{ \Illuminate\Support\Str::headline($storeOrder->status) }} - {{ $money($storeOrder->subtotal) }}

@if($storeOrder->rider?->user) Rider: {{ $storeOrder->rider->user->name }} @endif
@endforeach
@endif {{-- Chat --}} @php $customerSellerChat = $orderChats->get('customer_seller'); $customerDriverChat = $orderChats->get('customer_driver'); @endphp

Chat

Same order channels as the app

@foreach(['customer_seller' => ['title' => 'Seller chat', 'ticket' => $customerSellerChat], 'customer_driver' => ['title' => 'Driver chat', 'ticket' => $customerDriverChat]] as $channel => $chat)

{{ $chat['title'] }}

@if($chat['ticket']) @foreach($chat['ticket']->replies->take(-4) as $reply)
{{ \Illuminate\Support\Str::upper(\Illuminate\Support\Str::substr($reply->user?->name ?? 'U', 0, 1)) }}

{{ $reply->user?->name ?? trans_key('storefront.fallbacks.user') }}

{{ $reply->message }}

@endforeach @endif @if(!$canTrack)

Chat is closed after order completion.

@elseif($channel === 'customer_driver' && !$order->deliveryBoy && !$order->orderStores->contains(fn ($storeOrder) => $storeOrder->rider))

Driver chat opens after assignment.

@else
@csrf
@endif
@endforeach
{{-- Review --}}

Rate and review

{{ $review ? 'Your review is saved' : 'Share your experience' }}

@csrf
@endsection