@php $delivered = $product->where('status', 'D'); $shipped = $product->where('status', 'S'); $processed = $product->whereIn('status', ['H', 'PC']); @endphp

Your order has been delivered!

Dear {{$data['customer_data']->name}},

Your order has been successfully delivered!

We hope you had a great experience with us. Do let us know how we can make the ordering experience better for you and how else we can serve you!

Best Regards,
{{$data['site_data']->site_regards}}

Product Status

{{-- Delivered Products Table (FIRST) --}} @if($delivered->count())

Your product has been Delivered

@foreach($delivered as $pd) @endforeach
{{ $pd->pname }}

@endif {{-- Shipped Products Table (SECOND) --}} @if($shipped->count()) @php $lastTrack = null; @endphp

Already Shipped. Your product will be delivered soon

@foreach($shipped as $pd) @if($lastTrack !== $pd->track_no) @if($lastTrack !== null) {{-- Optional: Add a blank row or separator --}} @endif @php $lastTrack = $pd->track_no; @endphp @else @endif {{-- --}} @endforeach

Tracking No. - {{ $pd->track_no ?? 'N/A' }}

You can track your shipment by clicking the button below:

@if($pd->tracking_link) Track My Order @else N/A @endif

{{ $pd->pname }}
{{ $pd->pname }}
{{ $pd->pname }} {{ $pd->track_no ?? 'N/A' }} @if($pd->tracking_link) Track Here @else N/A @endif

@endif {{-- Processed Products Table (LAST) --}} @if($processed->count())

Your product will be Delivered soon

@foreach($processed as $pd) @endforeach
{{ $pd->pname }}
@endif

This message was sent to you by {{$data['site_data']->site_title}}.
If you didn’t create this account, contact {{$data['site_data']->site_title}} support.