@extends('frontend.layouts.app', ['title' => 'My Orders']) @section('content')
@include('frontend.layouts.sidebar', ['title' => 'Orders'])

My Orders

@if ($orders->isNotEmpty()) @foreach ($orders as $order)
Order Id:{{ $order->cart_id }}
Order Date:{{ $order->order_date }}
Status:{{ $order->order_status }}
Payment Method:{{ $order->payment_method }}
@if ($order->orderItems->isNotEmpty()) @php $total = 0; @endphp {{-- Order Items Row --}}
@foreach ($order->orderItems as $item)
    {{-- Product Image --}}
  • {{-- Product Info --}}
  • Price: {{ $item->product_name }}

    @php $mrp = $item->variation->mrp; $price = $item->variation->price; $percentOff = $mrp > 0 && $price > 0 ? round((($mrp - $price) / $mrp) * 100) : 0; @endphp {{ $percentOff }}% off MRP₹{{ $mrp }} ₹{{ $price }}
    @if ($item->variation->variation_attributes->isNotEmpty())

    {{ $item->variation->variation_attributes->map(function ($attribute) { return $attribute->attribute->attribute->name . ': ' . $attribute->attribute->name; })->implode(', ') }}

    @endif
    {{ $item->quantity }} Item{{ $item->quantity > 1 ? 's' : '' }}: ₹{{ $item->variation->price * $item->quantity }}
@php $total += $item->variation->price * $item->quantity; @endphp @endforeach {{-- ✅ Total AFTER the loop --}}
Total: ₹{{ $total }}
@endif
{{-- Shipping Address Row --}}
{{ $order->address->house_no }}
{{ $order->address->society }}
{{ $order->address->city }}
{{ $order->address->state }}
{{ $order->address->pincode }}
@endforeach @else

No Orders Found

@endif
{{-- Pagination --}}
{{ $orders->links('pagination::bootstrap-4') }}
@endsection