@extends('layouts.app') @section('title', 'Edit Order #' . $order->order_number) @section('content')

Edit Order #{{ $order->order_number }}

@if($order->store) Store: {{ $order->store->name }} @elseif($order->webhookSource) Source: {{ $order->webhookSource->name }} @elseif($order->is_manual) Source: Checkout Form @else Source: Manual Order @endif

@if(session('success'))

{{ session('success') }}

@endif @if(session('error'))

{{ session('error') }}

@endif @if($errors->any())

Please fix the following errors:

@endif
@csrf @method('PUT')

Order Status

Billing Information

@php // Support both WooCommerce format (first_name/last_name) and sales page format (name) $billingFirstName = $order->billing['first_name'] ?? ''; $billingLastName = $order->billing['last_name'] ?? ''; $billingName = $order->billing['name'] ?? ''; // If sales page format (has 'name'), split it or use as first name if ($billingName && !$billingFirstName && !$billingLastName) { $nameParts = explode(' ', $billingName, 2); $billingFirstName = $nameParts[0] ?? ''; $billingLastName = $nameParts[1] ?? ''; } // Support both WooCommerce format (address_1) and sales page format (address) $billingAddress = $order->billing['address_1'] ?? $order->billing['address'] ?? ''; @endphp

Shipping Information

@php // Support both WooCommerce format (first_name/last_name) and sales page format (name) $shippingFirstName = $order->shipping['first_name'] ?? ''; $shippingLastName = $order->shipping['last_name'] ?? ''; $shippingName = $order->shipping['name'] ?? ''; // If sales page format (has 'name'), split it or use as first name if ($shippingName && !$shippingFirstName && !$shippingLastName) { $nameParts = explode(' ', $shippingName, 2); $shippingFirstName = $nameParts[0] ?? ''; $shippingLastName = $nameParts[1] ?? ''; } // Support both WooCommerce format (address_1) and sales page format (address) $shippingAddress = $order->shipping['address_1'] ?? $order->shipping['address'] ?? ''; @endphp

Order Items

@foreach($order->getExpandedLineItems() as $expandedItem) @php $item = $expandedItem['item']; $isBundle = $expandedItem['is_bundle']; $bundleDetails = $expandedItem['bundle_details']; @endphp
{{ $item['name'] }} @if($isBundle) BUNDLE @endif
Qty: {{ $item['quantity'] }} × {{ $order->formatCurrency($item['price']) }}
@if($isBundle && $bundleDetails)
@foreach($bundleDetails['items'] as $bundleItem)
- {{ $bundleItem['name'] ?? $bundleItem['sku'] }} x{{ $bundleItem['quantity'] }} @if(isset($bundleItem['sku']) && $bundleItem['sku']) ({{ $bundleItem['sku'] }}) @endif
@endforeach
@endif
{{ $order->formatCurrency(($item['total'] ?? ($item['price'] * $item['quantity']))) }}
@endforeach
Cancel
@if($order->logs->count() > 0)

Order History

{{ $order->logs->count() }} {{ $order->logs->count() === 1 ? 'entry' : 'entries' }}
@foreach($order->logs->take(10) as $log)
{{ $log->user->name ?? 'System' }} {{ ucfirst($log->action) }}
{{ $log->created_at->format('M d, Y H:i:s') }}
@if($log->old_data && $log->new_data) @php $hasChanges = false; @endphp
@foreach($log->new_data as $key => $newValue) @php $oldValue = $log->old_data[$key] ?? null; // Skip if no change if ($oldValue === $newValue) { continue; } $hasChanges = true; // Format field name $fieldName = ucfirst(str_replace(['_', '.'], ' ', $key)); // Handle nested arrays (like billing, shipping) if (is_array($newValue) && is_array($oldValue)) { // This is a nested field like billing or shipping $nestedChanges = []; foreach ($newValue as $nestedKey => $nestedNewValue) { $nestedOldValue = $oldValue[$nestedKey] ?? ''; if ($nestedOldValue != $nestedNewValue) { $nestedChanges[] = [ 'field' => ucfirst(str_replace('_', ' ', $nestedKey)), 'old' => $nestedOldValue, 'new' => $nestedNewValue ]; } } if (count($nestedChanges) > 0) { echo '
'; echo '
' . $fieldName . ':
'; foreach ($nestedChanges as $change) { echo '
'; echo '' . $change['field'] . ': '; echo '' . ($change['old'] ?: '(empty)') . ''; echo ' → '; echo '' . ($change['new'] ?: '(empty)') . ''; echo '
'; } echo '
'; } } else { // Simple field change $displayOld = is_string($oldValue) ? $oldValue : json_encode($oldValue); $displayNew = is_string($newValue) ? $newValue : json_encode($newValue); @endphp
{{ $fieldName }}: {{ $displayOld ?: '(empty)' }}{{ $displayNew ?: '(empty)' }}
@php } @endphp @endforeach @if(!$hasChanges)
No changes detected
@endif
@else
No change details available
@endif
@endforeach @if($order->logs->count() > 10)

Showing 10 most recent entries. {{ $order->logs->count() - 10 }} older entries hidden for performance.

@endif
@endif
@endsection