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

Edit Order

Back
@include('alerts.alerts')
@csrf
Order Information
Shipping Information
@php $shipping = json_decode($order->shipping_info, true) ?? []; @endphp
@php $current_shipping = json_decode($order->shipping, true); $current_shipping_id = $current_shipping['id'] ?? null; $shipping_services = DB::table('shipping_services')->whereStatus(1)->get(); @endphp @if($current_shipping) Current: {{ $current_shipping['title'] ?? 'N/A' }} (৳{{ number_format($current_shipping['price'] ?? 0, 2) }}) @else No shipping method selected @endif
{{-- Hide Address Line 2 --}} {{--
--}} {{--
--}} {{-- Hide Country and Company - Set Bangladesh as default --}}
{{--
{{ __('Billing Information') }}
@php $billing = json_decode($order->billing_info, true) ?? []; @endphp
--}}
Order Products
@php $cart = json_decode($order->cart, true) ?? []; $total = 0; $option_price = 0; @endphp
@foreach($cart as $index => $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'); $unit_price = $main_price + $attribute_price; $line_total = $unit_price * $qty; $total += $main_price * $qty; $option_price += $attribute_price * $qty; // Debug cart structure in development if(config('app.debug')) { echo ""; } @endphp @endforeach @if($order->tax > 0) @endif @if(json_decode($order->shipping_info, true)) @php $shipping = json_decode($order->shipping_info, true); @endphp @endif
Product Attributes Quantity Unit Price Total Actions
@if(isset($item['photo'])) {{ $item_name }} @endif
{{ $item_name }} @if(isset($item['sku']))
SKU: {{ $item['sku'] }} @endif
@php // Resolve original item id from various cart formats $currentAttributes = isset($item['attribute']) ? $item['attribute'] : []; $itemId = $item['item']['id'] ?? null; if(!$itemId && isset($item['slug'])){ $itemId = \App\Models\Item::where('slug',$item['slug'])->value('id'); } if(!$itemId && isset($item['name'])){ $itemId = \App\Models\Item::where('name',$item['name'])->value('id'); } $originalItem = $itemId ? \App\Models\Item::with('attributes.options')->find($itemId) : null; $hasCartAttributes = !empty($currentAttributes); $hasAttributes = $originalItem && $originalItem->attributes->count() > 0; @endphp @if($hasAttributes)
@if($hasCartAttributes)
Current Selection:
@if(isset($currentAttributes['names'])) @foreach($currentAttributes['names'] as $ai => $nm) @if(isset($currentAttributes['option_name'][$ai])) {{ $nm }}: {{ $currentAttributes['option_name'][$ai] }} @endif @endforeach @endif
@endif
@foreach($originalItem->attributes as $attr) @if($attr->options->count()) @php $selectedVal = ''; if(isset($currentAttributes['names'])){ foreach($currentAttributes['names'] as $ai => $nm){ if(strtolower($nm) === strtolower($attr->name) && isset($currentAttributes['option_name'][$ai])){ $selectedVal = $currentAttributes['option_name'][$ai]; break; } } } @endphp
@endif @endforeach
@else No attributes available @endif
@if(isset($itemId) && $itemId) @endif @if(isset($item['attribute'])) @endif ৳{{ number_format($unit_price, 2) }} ৳{{ number_format($line_total, 2) }}
Subtotal: ৳{{ number_format($total + $option_price, 2) }}
Tax: ৳{{ number_format($order->tax, 2) }}
Shipping: ৳{{ number_format($shipping['pathao_shipping_cost'] ?? 0, 2) }}
Total: ৳{{ \App\Helpers\PriceHelper::OrderTotal($order) }}
You can adjust product quantities. Prices will be recalculated automatically.
Cancel
@endsection