@extends('frontEnd.layouts.master') @section('title','Invoice #' . $order->invoice_id) @section('content') @php // ১. পেমেন্ট ইনফো নেওয়া $payment = \App\Models\Payment::where('order_id', $order->id)->orderBy('id','desc')->first(); $gateway_status = $payment ? strtolower(trim($payment->payment_status)) : ''; $payment_method = $payment ? strtolower(trim($payment->payment_method)) : strtolower(trim($order->payment_method ?? '')); $admin_status = strtolower(trim($order->payment_status ?? '')); $order_status = strtolower(trim($order->status ?? '')); $grand_total = $order->amount; $paid_amount = 0; // পেমেন্ট রেকর্ড থেকে আসল টাকাটা বের করি if ($payment && !in_array($gateway_status, ['failed','cancel','cancelled','rejected'])) { $paid_amount = $payment->amount; } // COD FIX $is_cod = in_array($payment_method, ['cod','cash','cash_on_delivery','hand cash','hand_cash']); $is_order_completed = in_array($order_status, ['completed','delivered']) || in_array($admin_status, ['completed','delivered']); if ($is_cod && !$is_order_completed) { if ($paid_amount >= $grand_total) { $paid_amount = 0; } } // ADMIN PRIORITY if ($is_order_completed) { $paid_amount = $grand_total; } elseif (($paid_amount == 0 || !$payment) && in_array($admin_status, ['paid','success','approved'])) { $paid_amount = $grand_total; } // Due $due_amount = max(0, $grand_total - $paid_amount); $subtotal = ($order->amount + $order->discount) - $order->shipping_charge; // ⭐ ডিজিটাল ডাউনলোড লজিক — যদি ফুল পেইড হয় তবেই ডাউনলোড লিংক দেখাবে $is_fully_paid = ($paid_amount >= $grand_total); $downloads = $is_fully_paid ? \App\Models\DigitalDownload::where('order_id', $order->id)->get() : collect(); @endphp
পেমেন্ট সফল হওয়ায় আপনার ফাইলগুলো ডাউনলোডের জন্য উন্মুক্ত করা হয়েছে।
#{{$order->invoice_id}}
Date: {{$order->created_at->format('d M, Y')}}
| Product Description | Price | Qty | Total |
|---|---|---|---|
| {{$item->product_name}} @php $sizeDisplay = $item->size ? ($item->size->sizeName ?? $item->size->size_name ?? $item->size->name ?? null) : null; $colorDisplay = $item->color ? ($item->color->getDisplayName() ?? $item->color->colorName ?? $item->color->color_name ?? $item->color->name ?? null) : null; if (!$sizeDisplay && $item->product_size) { $s = \App\Models\Size::find($item->product_size); $sizeDisplay = $s ? ($s->sizeName ?? $s->size_name ?? null) : null; } if (!$colorDisplay && $item->product_color) { $c = \App\Models\Color::find($item->product_color); $colorDisplay = $c ? ($c->getDisplayName() ?? $c->colorName ?? $c->color_name ?? null) : null; } @endphp @if($sizeDisplay)Size: {{ $sizeDisplay }}@endif @if($colorDisplay)Color: {{ $colorDisplay }}@endif | ৳{{number_format($item->sale_price, 2)}} | {{$item->qty}} | ৳{{number_format($item->sale_price * $item->qty, 2)}} |
Thank you for your business! This is a computer-generated invoice.
{{$generalsetting->name}}