@extends('backEnd.layouts.master') @section('title','Order Process') @section('css') @endsection @section('content')

Order Process [Invoice : #{{$data->invoice_id}}]

@php // Check if this is a reseller order (once, outside loop) // Reseller orders ALWAYS have customer_payable_amount field set $isResellerOrderItem = !empty($data->customer_payable_amount); // For reseller orders: calculate custom_price from customer_payable_amount $customPrice = null; $totalProductValue = 0; if ($isResellerOrderItem && $data->customer_payable_amount) { $customPrice = $data->customer_payable_amount - ($data->shipping_charge ?? 0); // Calculate total of all products (sum of sale_price * qty) foreach ($data->orderdetails as $od) { $totalProductValue += ($od->sale_price * $od->qty); } } @endphp @foreach($data->orderdetails as $key => $product) @php // For reseller orders: Calculate price from customer_payable_amount proportionally // customer_payable_amount = custom_price + shipping // custom_price = reseller যে দামে sell করেছে (total) // For normal orders: show sale_price (main price) if ($isResellerOrderItem && $customPrice && $totalProductValue > 0) { // Reseller order: Calculate per product price from customer_payable_amount // This product's share = (this product's value / total value) * custom_price $thisProductValue = $product->sale_price * $product->qty; $thisProductShare = ($thisProductValue / $totalProductValue) * $customPrice; $displayPrice = $thisProductShare / $product->qty; // Per unit price } else { // Normal order: show sale_price (main price) $displayPrice = $product->sale_price; } @endphp {{-- ✅ Product Image --}} {{-- ✅ Product Name --}} @php $sizeDisplay = 'N/A'; if ($product->size) { $sizeDisplay = $product->size->sizeName ?? $product->size->size_name ?? $product->size->name ?? 'N/A'; } elseif ($product->product_size) { // If product_size is an ID, fetch the Size model $s = \App\Models\Size::find($product->product_size); if ($s) { $sizeDisplay = $s->sizeName ?? $s->size_name ?? 'N/A'; } elseif (!is_numeric($product->product_size)) { // If it's not numeric, it might be a direct size name string $sizeDisplay = $product->product_size; } } @endphp @endforeach
SL Image Product Color Size Price Qty Total
{{ $key + 1 }} Product Image {{ $product->product_name }} {{ ($product->color && $product->color->name) ? $product->color->name : ($product->product_color ?: 'N/A') }}{{ $sizeDisplay }} ৳{{ number_format($displayPrice, 2) }} {{ $product->qty }} ৳{{ number_format($displayPrice * $product->qty, 2) }}
@csrf
@php $paymentInfo = DB::table('orders') ->select('payment_gateway', 'payment_status') ->where('id', $data->id) ->first(); @endphp
Payment Information

@if(!empty($paymentInfo->payment_gateway)) {{ strtoupper($paymentInfo->payment_gateway) }} @else Not Found @endif
@php // Check if this is a reseller order $isResellerOrder = !empty($data->customer_payable_amount); // Calculate subtotal if ($isResellerOrder && $data->customer_payable_amount) { // Reseller order: subtotal = customer_payable_amount - shipping $subtotal = $data->customer_payable_amount - ($data->shipping_charge ?? 0); } else { // Normal customer order: calculate from sale_price $subtotal = $data->orderdetails->sum(function($item) { return $item->sale_price * $item->qty; }); } $shipping = $data->shipping_charge ?? 0; $discount = $data->discount ?? 0; $finalTotal = $isResellerOrder ? ($data->customer_payable_amount ?? $data->amount) : $data->amount; @endphp
Order Amount Information
@if($isResellerOrder)
Reseller Order - Showing customer payable amount
@endif
৳{{ number_format($subtotal, 2) }}
৳{{ number_format($shipping, 2) }}
৳{{ number_format($discount, 2) }}
৳{{ number_format($finalTotal, 2) }}
@endsection