@php
// Currency symbol and position
$symbol = session('currency_symbol', '$');
$shortcut = session('currency_shortcut', 'USD');
function formatCurrency($symbol, $shortcut, $amount) {
if ($shortcut == 'USD') {
return $symbol . ' ' . number_format($amount, 2);
}
if ($shortcut == 'INR') {
return $symbol . ' ' . number_format($amount, 2);
}
if ($shortcut == 'AED') {
return number_format($amount, 2) . ' ' . $symbol;
}
// default
return $symbol . ' ' . number_format($amount, 2);
}
@endphp
My Orders | Uthhan Global
@include('layouts.header')
| Product |
Qty |
Status |
Price (Subtotal) |
Total (With Charges) |
Action |
@forelse($orders as $order)
@php
$items = $order->items;
$firstItem = $items->first();
@endphp
@if($firstItem)
@php
// total quantity in this order
$totalQty = $items->sum('product_quantity');
// order-level currency data
$symbol = $firstItem->converted_currency_symbol ?? session('currency_symbol', '$');
$shortcut = session('currency_shortcut', 'USD');
// SUBTOTAL = sum of each item line total (converted)
$subtotalConverted = $items->sum(function ($item) {
if (!is_null($item->sub_total_converted)) {
return (float) $item->sub_total_converted;
}
$rate = $item->converted_currency_value ?? (float) session('currency_rate', 1);
$qty = $item->product_quantity ?? 1;
$base = ($item->product_price ?? 0) * $qty;
return $base * $rate;
});
// SHIPPING (converted) – from first row (order-level)
$shippingConverted =
$firstItem->shipping_charge_total_converted
?? (
($firstItem->shipping_charge_converted ?? 0)
+ ($firstItem->fuel_surcharge_converted ?? 0)
+ ($firstItem->gst_converted ?? 0)
+ ($firstItem->payment_gateway_charge_converted ?? 0)
);
// DISCOUNT (converted)
$discountConverted = $firstItem->discounted_per ?? 0;
// GRAND TOTAL (converted)
$grandTotalConverted =
$firstItem->final_amount_converted
?? ($subtotalConverted + $shippingConverted - $discountConverted);
// For product display – show first product + count
$productTitle = $firstItem->product_name;
if ($items->count() > 1) {
$productTitle .= ' +' . ($items->count() - 1) . ' more';
}
$productImage = $firstItem->product_image
? asset($firstItem->product_image)
: asset('img/shop-cart/cp-1.jpg');
$orderStatusRaw = $order->order_status ?? $order->status ?? 'pending';
$statusSlug = strtolower($orderStatusRaw);
$statusClass = 'order-status-pending';
if (in_array($statusSlug, ['completed', 'paid'])) {
$statusClass = 'order-status-completed';
} elseif (in_array($statusSlug, ['cancelled', 'failed'])) {
$statusClass = 'order-status-cancelled';
}
@endphp
{{-- Product cell --}}
{{ $productTitle }}
Order #{{ $order->order_id }}
{{ optional($order->created_at)->format('d M, Y') }}
|
{{-- Qty --}}
{{ $totalQty }}
|
{{-- Status --}}
{{ strtoupper($orderStatusRaw) }}
|
{{-- Price = subtotal of products --}}
{{ formatCurrency($symbol, $shortcut, $subtotalConverted) }}
|
{{-- Total = subtotal + shipping/charges - discount (grand total) --}}
{{ formatCurrency($symbol, $shortcut, $grandTotalConverted) }}
|
{{-- Action --}}
View Details
|
@endif
@empty
|
You haven’t placed any orders yet.
|
@endforelse
@include('layouts.footer')
{{-- Search popup etc... --}}
script src="{{ asset('js/jquery-ui.min.js') }}">