@foreach($chunk as $order)
@php
$totalQty = $order->orderdetails->sum('qty');
$payMethod = strtolower($order->payment_gateway ?? ($order->payment ? $order->payment->payment_method : ''));
$isCOD = !in_array($payMethod, ['bkash','nagad','rocket','card','online','paid']);
$trkId = $order->courier_tracking_id ?? $order->consignment_id ?? null;
$courier = $order->courier_type ?? ($trkId ? 'steadfast' : null);
$cClass = $courier ? strtolower($courier) : 'none';
@endphp
@if($isCOD)
COD
@endif
{{-- TOP: FROM + Invoice --}}
From
{{ $generalsetting->name }}
{{ $contact->phone ?? '' }}
@if($contact->address) · {{ Str::limit($contact->address,35) }}@endif
Invoice
#{{ $order->invoice_id }}
{{ $order->created_at->format('d M Y') }}
{{-- TO: Recipient --}}
► Ship To
@if($order->shipping)
{{ $order->shipping->name ?? '—' }}
📞 {{ $order->shipping->phone ?? '' }}
{{ $order->shipping->address ?? '' }}
@if($order->shipping->area), {{ $order->shipping->area }}@endif
@else
— No Shipping Info —
@endif
{{-- Products with image, size, color --}}
@foreach($order->orderdetails as $item)
@php
$imgPath = $item->image ? $item->image->image : null;
$sz = $item->size ? ($item->size->sizeName ?? null) : null;
if (!$sz && $item->product_size) {
$sm = \App\Models\Size::find($item->product_size);
$sz = $sm ? ($sm->sizeName ?? null) : (is_numeric($item->product_size) ? null : $item->product_size);
}
$cl = $item->color ? ($item->color->colorName ?? null) : null;
if (!$cl && $item->product_color && !is_numeric($item->product_color)) { $cl = $item->product_color; }
@endphp
@if($imgPath)
📦
@else
📦
@endif
{{ Str::limit($item->product_name, 38) }}
@if($sz)Sz: {{ $sz }}@endif
@if($cl){{ $cl }}@endif
× {{ $item->qty }}
@endforeach
{{-- Bottom: Courier + Amount --}}
🚚 Courier
@if($courier === 'steadfast') 🔵 Steadfast
@elseif($courier === 'pathao') 🔷 Pathao
@elseif($courier === 'redx') 🟠 RedX
@elseif($courier) {{ ucfirst($courier) }}
@else — Not Assigned —
@endif
@if($trkId)
ID: {{ $trkId }}
@endif
@if($order->courier_sent_at)
Sent: {{ \Carbon\Carbon::parse($order->courier_sent_at)->format('d M Y') }}
@endif
Total
৳{{ number_format($order->amount,0) }}
{{ $totalQty }} {{ $totalQty>1?'pcs':'pc' }}
@endforeach
@for($i = $chunk->count(); $i < 8; $i++)
@endfor
@endforeach