@extends('master.back') @section('content')

{{ __('Order Invoice') }}

{{ __('Back') }} {{ __('print') }}
@php if ($order->state) { $state = json_decode($order->state, true); } else { $state = []; } @endphp
Logo
{{ __('Order Details :') }}
{{ __('Transaction Id :') }}{{ $order->txnid }}
{{ __('Order Id :') }}{{ $order->transaction_number }}
{{ __('Order Date :') }}{{ $order->created_at->format('M d, Y') }}
{{ __('Payment Status :') }} @if ($order->payment_status == 'Paid')
{{ __('Paid') }}
@else
{{ __('Unpaid') }}
@endif
{{ __('Payment Method :') }}{{ $order->payment_method }}


{{ __('Shipping Address :') }}
@php $ship = json_decode($order->shipping_info, true); // Ensure shipping info exists with proper fallbacks if (!$ship || empty($ship)) { $ship = []; } @endphp {{ __('Name') }}: {{ ($ship['ship_first_name'] ?? '') }}
{{ __('Email') }}: {{ $ship['ship_email'] ?? 'N/A' }}
{{ __('Phone') }}: {{ $ship['ship_phone'] ?? 'N/A' }}
@if (isset($ship['ship_address1'])) {{ __('Address') }}: {{ $ship['ship_address1'] }},
@endif @if (isset($ship['ship_country'])) {{ __('Country') }}: {{ $ship['ship_country'] }}
@endif @if (isset($ship['ship_city'])) {{ __('City') }}: {{ $ship['ship_city'] }}
@endif @if (isset($state['name'])) {{ __('State') }}: {{ $state['name'] }}
@endif @if (isset($ship['ship_zip'])) {{ __('Zip') }}: {{ $ship['ship_zip'] }}
@endif @if (isset($ship['ship_company'])) {{ __('Company') }}: {{ $ship['ship_company'] }}
@endif {{-- Pathao Information --}} @if (isset($ship['pathao_city_id']) || isset($ship['pathao_zone_id']) || isset($ship['pathao_area_id']))
{{ __('Delivery Info') }}:
@php $pathaoNames = \App\Http\Controllers\Front\CheckoutController::getPathaoNames($ship); @endphp @if (isset($ship['pathao_city_id'])) {{ __('City') }}: {{ $pathaoNames['city_name'] }} {{-- (ID: {{ $ship['pathao_city_id'] }}) --}}
@endif @if (isset($ship['pathao_zone_id'])) {{ __('Zone') }}: {{ $pathaoNames['zone_name'] }} {{-- (ID: {{ $ship['pathao_zone_id'] }}) --}}
@endif @if (isset($ship['pathao_area_id'])) {{ __('Area') }}: {{ $pathaoNames['area_name'] }} {{--(ID: {{ $ship['pathao_area_id'] }}) --}}
@endif @if (isset($ship['pathao_shipping_cost'])) {{ __('Shipping Cost') }}: {{ '৳' }} {{($ship['pathao_shipping_cost']) }}
@endif @endif
{{--
{{ __('Billing Address :') }}
@php $bill = json_decode($order->billing_info, true); // Handle missing billing info by falling back to shipping info if (!$bill || empty($bill)) { $ship = json_decode($order->shipping_info, true); $bill = $ship ? [ 'bill_first_name' => $ship['ship_first_name'] ?? '', 'bill_last_name' => $ship['ship_last_name'] ?? '', 'bill_email' => $ship['ship_email'] ?? '', 'bill_phone' => $ship['ship_phone'] ?? '', 'bill_address1' => $ship['ship_address1'] ?? '', 'bill_address2' => $ship['ship_address2'] ?? '', 'bill_city' => $ship['ship_city'] ?? '', 'bill_zip' => $ship['ship_zip'] ?? '', 'bill_country' => $ship['ship_country'] ?? '', 'bill_company' => $ship['ship_company'] ?? '' ] : []; } @endphp {{ __('Name') }}: {{ ($bill['bill_first_name'] ?? '') }} {{ ($bill['bill_last_name'] ?? '') }}
{{ __('Email') }}: {{ $bill['bill_email'] ?? 'N/A' }}
{{ __('Phone') }}: {{ $bill['bill_phone'] ?? 'N/A' }}
@if (isset($bill['bill_address1'])) {{ __('Address') }}: {{ $bill['bill_address1'] }}, {{ isset($bill['bill_address2']) ? $bill['bill_address2'] : '' }}
@endif @if (isset($bill['bill_country'])) {{ __('Country') }}: {{ $bill['bill_country'] }}
@endif @if (isset($bill['bill_city'])) {{ __('City') }}: {{ $bill['bill_city'] }}
@endif @if (isset($state['name'])) {{ __('State') }}: {{ $state['name'] }}
@endif @if (isset($bill['bill_zip'])) {{ __('Zip') }}: {{ $bill['bill_zip'] }}
@endif @if (isset($bill['bill_company'])) {{ __('Company') }}: {{ $bill['bill_company'] }}
@endif
--}}
@php $option_price = 0; $total = 0; $subtotal = 0; @endphp @foreach (json_decode($order->cart, true) as $item) @php // Handle different cart structures for backward compatibility $main_price = isset($item['main_price']) ? $item['main_price'] : (isset($item['price']) ? $item['price'] : 0); $attribute_price = isset($item['attribute_price']) ? $item['attribute_price'] : 0; $qty = isset($item['qty']) ? $item['qty'] : 1; $item_name = isset($item['name']) ? $item['name'] : (isset($item['item']['name']) ? $item['item']['name'] : 'Product'); $total += $main_price * $qty; $option_price += $attribute_price; $grandSubtotal = $total + $option_price; $unit_price = $main_price + $attribute_price; $line_total = isset($item['total']) ? $item['total'] : ($unit_price * $qty); $subtotal += $line_total; @endphp @endforeach @if ($order->tax != 0) @endif @if (json_decode($order->discount, true)) @php $discount = json_decode($order->discount, true); @endphp @endif {{-- @if (json_decode($order->shipping, true)) @php $shipping = json_decode($order->shipping, true); @endphp @endif --}} @if (json_decode($order->state_price, true)) @endif @php $ship = json_decode($order->shipping_info, true); @endphp
{{ __('Products') }} {{ __('Attribute') }} {{ __('Quantity') }} {{ __('Price') }}
{{ $item_name }} @if (isset($item['attribute']['names'])) @foreach ($item['attribute']['names'] as $index => $name) {{ $name }} : {{ $item['attribute']['option_name'][$index] }}
@endforeach @else -- @endif
{{ $qty }} @php $total_price = $main_price + $attribute_price; @endphp @if ($setting->currency_direction == 1) {{ $order->currency_sign }}{{ round($total_price * $order->currency_value, 2) }} @else {{ round($total_price * $order->currency_value, 2) }}{{ $order->currency_sign }} @endif
{{ __('Tax') }} @if ($setting->currency_direction == 1) {{ $order->currency_sign }}{{ round($order->tax * $order->currency_value, 2) }} @else {{ round($order->tax * $order->currency_value, 2) }}{{ $order->currency_sign }} @endif
{{ __('Coupon discount') }} ({{ $discount['code']['code_name'] }}) @if ($setting->currency_direction == 1) -{{ $order->currency_sign }}{{ round($discount['discount'] * $order->currency_value, 2) }} @else -{{ round($discount['discount'] * $order->currency_value, 2) }}{{ $order->currency_sign }} @endif
{{ __('Shipping') }} @if ($setting->currency_direction == 1) {{ $order->currency_sign }}{{ round($shipping['price'] * $order->currency_value, 2) }} @else {{ round($shipping['price'] * $order->currency_value, 2) }}{{ $order->currency_sign }} @endif
{{ __('State Tax') }} @if ($setting->currency_direction == 1) {{ isset($state['type']) && $state['type'] == 'percentage' ? ' (' . $state['price'] . '%) ' : '' }} {{ $order->currency_sign }}{{ round($order['state_price'] * $order->currency_value, 2) }} @else {{ isset($state['type']) && $state['type'] == 'percentage' ? ' (' . $state['price'] . '%) ' : '' }} {{ round($order['state_price'] * $order->currency_value, 2) }}{{ $order->currency_sign }} @endif
@if ($order->payment_method == 'Cash On Delivery') {{ __('Sub Total') }} @else {{ __('Sub Total amount due') }} @endif @if ($setting->currency_direction == 1) {{ $order->currency_sign }}{{ round($subtotal * 1, 2) }} @else {{ round($subtotal* 1, 2) }}{{ $order->currency_sign }} @endif
{{ __('Shipping') }} @if ($setting->currency_direction == 1) {{ '৳' }}{{ round($ship['pathao_shipping_cost'] * 1, 2) }} @else {{ round($ship['pathao_shipping_cost'] * 1, 2) }}{{ '৳' }} @endif
@if ($order->payment_method == 'Cash On Delivery') {{ __('Total amount') }} @else {{ __('Total amount due') }} @endif @if ($setting->currency_direction == 1) {{ $order->currency_sign }}{{ PriceHelper::OrderTotal($order) }} @else {{ PriceHelper::OrderTotal($order) }}{{ $order->currency_sign }} @endif
@endsection