{{($key+1)}}
{{ $order->id }}
@php
$sellerName = auth()->user()->name ?? 'Seller';
$productDetails = $order->items->map(function($item) {
$variant = $item->productVariant;
$product = $variant?->product;
if (!$product) return '';
$brand = $product->brand?->title ?? 'AR';
$attrs = $variant->getAttributeSummary();
return $product->title . ' (' . $brand . ($attrs ? ' | ' . $attrs : '') . ' | Qty: ' . $item->quantity . ')';
})->filter()->implode("\n");
$courierName = $order->shipper?->title ?? 'N/A';
$trackingNumber = $order->shipping_ref ?? 'N/A';
$amount = $order->base_amount ?? 0;
$sellerPhone = $order->sellerProfile?->phone ?? auth()->user()->seller_profile?->phone ?? '0332-3399562';
$whatsappMessage = "This message is from Dear " . $sellerName . "\n\n";
$whatsappMessage .= "This is to inform you that your order has been dispatched and is en route.\n";
$whatsappMessage .= "It will be arriving soon in your city for delivery.\n\n";
$whatsappMessage .= "Order details are as follows:\n";
$whatsappMessage .= "Product Name: " . $productDetails . "\n";
$whatsappMessage .= "Courier: " . $courierName . "\n";
$whatsappMessage .= "Tracking Number: " . $trackingNumber . "\n";
$whatsappMessage .= "Amount to be Paid: Rs. " . number_format($amount) . "\n\n";
$whatsappMessage .= "In case of any query or complaint, you can contact us at " . $sellerPhone . ".\n";
$whatsappMessage .= "Thank you!";
$encodedMessage = urlencode($whatsappMessage);
// Format phone number for WhatsApp (Pakistan format: 92XXXXXXXXXX)
$phoneNumber = preg_replace('/[^0-9]/', '', $order->customer_phone);
// Remove leading zeros
$phoneNumber = ltrim($phoneNumber, '0');
// If doesn't start with 92, add it (Pakistan country code)
if (substr($phoneNumber, 0, 2) !== '92') {
$phoneNumber = '92' . $phoneNumber;
}
@endphp
@php
$showSellerStatus = !in_array($order->status, [
\App\Models\Order::STATUS_CANCELLED,
\App\Models\Order::STATUS_ON_HOLD,
\App\Models\Order::STATUS_PENDING,
\App\Models\Order::STATUS_READY_TO_PROCESS
]);
@endphp
@if($showSellerStatus)
@if($order->seller_status == \App\Models\Order::SELLER_STATUS_PAID)
Paid
@else
Unpaid
@endif
@endif
{{\App\Helpers\Helper::to_local_date($order->created_at, 'Y-m-d')}}
{{\App\Helpers\Helper::to_local_date($order->created_at, 'H:i:s')}}
{{ $order->base_amount }}
{{$order->seller_profit_amount}}
{{\App\Models\Order::STATUS[$order->status]}}
-
{{ $order->shipping_ref }}
{{$order->tracking_status}}
{{-- Tracking Button: Show for all except Pending --}}
@if(!in_array($order->status,[\App\Models\Order::STATUS_PENDING]))
{{-- Normal icon (shown when not loading) --}}
{{-- Loader spinner (shown only while loading) --}}
@endif
{{-- Cancel Button: Only for Pending orders --}}
@if($order->status === \App\Models\Order::STATUS_PENDING)
@endif
{{-- Request Button: ONLY show for Shipped status --}}
@if($order->status === \App\Models\Order::STATUS_SHIPPED)
Create Request
@if(isset($unreadCounts[$order->id]) && $unreadCounts[$order->id] > 0)
{{ $unreadCounts[$order->id] }}
unread messages
@endif
@endif