@extends('layouts.shop') @section('title', 'Order #' . $order->order_number) @push('head_scripts') @if($order->status === 'shipped' && $order->deliveryAgent) @endif @endpush @section('content')

Order Details

#{{ $order->order_number }} Placed on {{ $order->created_at->format('M d, Y') }} at {{ $order->created_at->format('h:i A') }}
@csrf
Invoice @php $statusLabel = ucfirst($order->status); $statusColor = match ($order->status) { 'completed' => 'bg-green-500', 'processing' => 'bg-blue-500', 'cancelled' => 'bg-red-500', 'shipped' => 'bg-indigo-500', default => 'bg-yellow-500' }; if ($order->returnRequest) { $rStatus = $order->returnRequest->status; $statusLabel = 'Return ' . ucfirst(str_replace('_', ' ', $rStatus)); if ($rStatus == 'requested') $statusColor = 'bg-yellow-500'; elseif ($rStatus == 'approved') $statusColor = 'bg-blue-500'; elseif ($rStatus == 'rejected') $statusColor = 'bg-red-500'; elseif ($rStatus == 'received') $statusColor = 'bg-purple-500'; elseif ($rStatus == 'refund_initiated') $statusColor = 'bg-indigo-500'; elseif ($rStatus == 'refunded') $statusColor = 'bg-green-500'; } @endphp {{ $statusLabel }}
@php $steps = [ ['status' => 'pending', 'label' => 'Placed', 'icon' => 'M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z'], ['status' => 'processing', 'label' => 'Processed', 'icon' => 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4'], ['status' => 'shipped', 'label' => 'In Transit', 'icon' => 'M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 011 1v2a1 1 0 01-1 1m0-4h3m-11 0h1m11 0a1 1 0 001-1V7a1 1 0 00-1-1h-3.3a1 1 0 00-1 1v9h3.3z'], ['status' => 'completed', 'label' => 'Delivered', 'icon' => 'M5 13l4 4L19 7'], ]; $histories = $order->statusHistories->keyBy('status'); $isCancelled = $order->status === 'cancelled'; if ($order->returnRequest) { $ret = $order->returnRequest; // Add Return Requested Step $steps[] = ['status' => 'return_requested', 'label' => 'Return Req.', 'icon' => 'M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6']; // Use created_at for request time $histories->put('return_requested', $ret); if (in_array($ret->status, ['approved', 'received', 'refund_initiated', 'refunded'])) { $steps[] = ['status' => 'return_approved', 'label' => 'Return Appr.', 'icon' => 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z']; // Use updated_at as proxy for approval time if active, else it's approximate $histories->put('return_approved', (object) ['created_at' => $ret->updated_at]); } if ($ret->status == 'rejected') { $steps[] = ['status' => 'return_rejected', 'label' => 'Return Rejected', 'icon' => 'M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z']; $histories->put('return_rejected', (object) ['created_at' => $ret->updated_at]); } if ($ret->status == 'refunded') { $steps[] = ['status' => 'refunded', 'label' => 'Refunded', 'icon' => 'M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z']; $histories->put('refunded', (object) ['created_at' => $ret->refunded_at]); } } $furthestStep = -1; foreach ($steps as $index => $step) { if ($histories->has($step['status'])) $furthestStep = $index; } @endphp @php $totalShownSteps = count($steps) + ($isCancelled ? 1 : 0); $progressPercentage = ($totalShownSteps > 1) ? ($furthestStep / ($totalShownSteps - 1)) : 0; $statusLabelColors = [ 'pending' => 'text-indigo-600', 'processing' => 'text-blue-600', 'shipped' => 'text-amber-600', 'completed' => 'text-green-600', ]; @endphp
@if($furthestStep >= 0 && !$isCancelled)
@endif
@foreach ($steps as $index => $step) @php $isActive = $histories->has($step['status']); $isCurrent = $order->status === $step['status']; $history = $histories->get($step['status']); @endphp
{{ $step['label'] }} @if($isActive && $history) @endif
@endforeach @if($isCancelled)
Cancelled @php $cancelHistory = $histories->get('cancelled'); @endphp @if($cancelHistory) @endif
@endif
Shipping To
@if($order->shippingAddress)

{{ $order->shippingAddress->name }}

{{ $order->shippingAddress->address_line1 }}
@if($order->shippingAddress->address_line2) {{ $order->shippingAddress->address_line2 }}
@endif {{ $order->shippingAddress->city }}, {{ $order->shippingAddress->state }} - {{ $order->shippingAddress->postal_code }}
{{ $order->shippingAddress->country }}
Phone: {{ $order->shippingAddress->phone }}

@else

No shipping details provided.

@endif
Payment Info

{{ str_replace('_', ' ', $order->payment_method ?? 'Not selected') }}

{{ ucfirst($order->payment_status) }} @if($order->payment_method == 'razorpay' || $order->payment_method == 'phonepe')
@if($order->transaction_id)
Transaction ID {{ $order->transaction_id }}
@endif
@endif @if($order->status == 'cancelled' && $order->cancellation_reason)

Reason for Cancellation

"{{ $order->cancellation_reason }}"

@endif
@if($order->deliveryAgent)
Delivery Executive

{{ $order->deliveryAgent->user->name }}

Lugani Verified Delivery Partner

@if($order->order_scope === 'Local' && $order->status === 'shipped') Call Executive @endif
@endif
@if($order->status === 'shipped' && $order->deliveryAgent)

Live Delivery Tracking

Updating every 10s

Current Location

Waiting for signal...

@endif @if($order->status === 'completed')

{{ $order->productReviews->isNotEmpty() ? 'Your Feedback' : 'Share Your Experience' }}

{{ $order->productReviews->isNotEmpty() ? 'Thank you for rating your experience!' : 'Rate your products and the delivery executive' }}

@if($order->productReviews->isEmpty())
@csrf
@foreach($order->items as $index => $item)
@if($item->variation && $item->variation->image_path) @elseif($item->product->images->isNotEmpty()) @endif

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

@endforeach
@if($order->deliveryAgent && !$order->agentRating)

Rate {{ $order->deliveryAgent->user->name }}

How was your delivery experience?

@endif
@else
@endif
@endif

Order Summary

{{ $order->items->count() }} Items
@foreach($order->items as $item) @endforeach @if($order->discount > 0) @endif @if($order->gift_card_discount > 0) @endif @if($order->points_discount > 0) @endif
Product Details Price Qty Subtotal
@if($item->variation && $item->variation->image_path) @elseif($item->product->images->isNotEmpty()) @else
NO IMG
@endif
{{ $item->product->name }} @if(isset($item->options['attributes']))
@foreach($item->options['attributes'] as $attr) {{ $attr['attribute'] }}: {{ $attr['value'] }} @endforeach
@endif
₹{{ number_format($item->price, 2) }} {{ $item->quantity }} ₹{{ number_format($item->total, 2) }}
Subtotal ₹{{ number_format($order->subtotal, 2) }}
Shipping Fee ₹{{ number_format($order->shipping_cost, 2) }}
Promo Discount -₹{{ number_format($order->discount, 2) }}
Gift Card Applied -₹{{ number_format($order->gift_card_discount, 2) }}
Points Spent ({{ $order->points_redeemed }}) -₹{{ number_format($order->points_discount, 2) }}
Total Amount ₹{{ number_format($order->total, 2) }}
{{-- Cancellation --}} @if(in_array($order->status, ['pending', 'processing', 'processed']))

Cancel Order

Placing an order is exciting, but we understand if you changed your mind.

@csrf
@endif {{-- Return Order --}} @if($order->status === 'completed' && !$order->returnRequest && $order->items->every(fn($item) => $item->product->is_returnable)) {{-- Optional: Check return window here visually or handled in controller --}}

Request Return

Detailed information helps us process your return faster.

@csrf
@endif @if($order->returnRequest)

Return Request Status: {{ ucfirst(str_replace('_', ' ', $order->returnRequest->status)) }}

{{ $order->returnRequest->admin_note ?? 'Your request is being processed.' }}

@if($order->returnRequest->refund_amount)

Refund Amount: ₹{{ $order->returnRequest->refund_amount }}

@endif @if($order->returnRequest->refund_proof_path) @endif
@endif
@endsection