@extends('layouts.page') @section('head') @include('elements.seo', ['title'=>'Pedido #'.$order->id ]) @endsection @section('content')
Volver a Mis Pedidos

Pedido #{{ $order->id }}

Realizado el {{ $order->created_at->subHour(5)->format('d M Y') }}

@if(auth()->user()?->hasAnyRole(['admin', 'seller', 'supervisor'])) @endif

Estado del Pedido

@php // Define status configurations $statusLabels = [ 0 => 'Pendiente', 1 => 'Procesado', 2 => 'Error', 3 => 'Error WS', ]; $statusColors = [ 0 => 'blue', // Pendiente - azul 1 => 'green', // Procesado - verde 2 => 'red', // Error - rojo 3 => 'red', // Error WS - rojo ]; $currentStatusLabel = $statusLabels[$order->status_id] ?? 'Desconocido'; $currentStatusColor = $statusColors[$order->status_id] ?? 'gray'; // Siempre mostrar estos 3 pasos $statuses = [ [ 'label' => 'Pedido realizado', 'date' => $order->created_at->subHour(5)->format('d M Y, g:i A'), 'completed' => true, 'color' => 'green' ], [ 'label' => 'Pedido Pendiente', 'date' => $order->created_at->subHour(5)->format('d M Y, g:i A'), 'completed' => true, 'color' => 'green' ], [ 'label' => $currentStatusLabel, 'date' => $order->updated_at->subHour(5)->format('d M Y, g:i A'), 'completed' => true, 'color' => $currentStatusColor ], ]; @endphp
@foreach($statuses as $status)

{{ $status['label'] }}

{{ $status['date'] }}

@endforeach

Productos

@foreach ($order->products as $product)
@if($product->product->images && $product->product->images->first()) {{ $product->product->name }} @else @endif

{{ $product->product->name }}

${{ number_format($product->price, 0) }}

Cantidad: {{ $product->quantity }}

${{ number_format($product->price * $product->quantity, 0) }}

@endforeach
@if($order->bonifications->count() > 0)

Bonificaciones aplicadas

@foreach ($order->bonifications as $gift)

{{ $gift->bonification->name ?? 'Bonificación' }}: {{ $gift->quantity }} {{ $gift->quantity === 1 ? 'unidad' : 'unidades' }} de {{ $gift->product->name ?? 'Obsequio' }}.

@endforeach
@endif @if($order->delivery_method || $order->observations)

Información de Envío

@if($order->delivery_method)

{{ ucwords(strtolower($order->delivery_method)) }}

@if($order->delivery_date)

{{ ucwords(\Carbon\Carbon::parse($order->delivery_date)->locale('es')->translatedFormat('l d \d\e F')) }}

@endif
@endif @if($order->shipping_provider === \App\Models\Order::SHIPPING_PROVIDER_COORDINADORA)

Seguimiento Coordinadora

Estado: {{ $order->coordinadora_status_text ?? 'Pendiente de procesamiento' }}

Guía: {{ $order->coordinadora_guide_number ?? '-' }}

Última actualización: {{ optional($order->coordinadora_status_at)->format('d/m/Y H:i') ?? '-' }}

@endif @if($order->observations)

Observaciones

{{ $order->observations }}

@endif
@endif

Resumen del Pedido

@php $displayTotal = $order->totalWithTax(); $displayDiscount = $order->discountWithTax(); $displayShipping = (float) ($order->shipping_quote_amount ?? 0); @endphp
Subtotal ${{ number_format($displayTotal + $displayDiscount, 0) }}
@if($displayDiscount > 0)
Descuento -${{ number_format($displayDiscount, 0) }}
@endif @if($displayShipping > 0)
Envío 48H (estimado) ${{ number_format($displayShipping, 0) }}
@endif @if(($order->retention_total ?? 0) > 0)

Retenciones ({{ $order->tax_group ?? '—' }})

@if(($order->retention_fuente ?? 0) > 0)
Retención en la fuente ${{ number_format($order->retention_fuente, 0) }}
@endif @if(($order->retention_iva ?? 0) > 0)
Retención de IVA ${{ number_format($order->retention_iva, 0) }}
@endif
@endif
Total ${{ number_format($displayTotal + $displayShipping, 0) }}

Dirección de Entrega

@php $zoneSnapshot = is_array($order->zone_snapshot) ? $order->zone_snapshot : []; $zone = $order->zone; $deliveryAddress = $zoneSnapshot['address'] ?? ($zone?->address); $deliveryZone = $zoneSnapshot['zone'] ?? ($zone?->zone); $deliveryRoute = $zoneSnapshot['route'] ?? ($zone?->route); $deliveryCode = $zoneSnapshot['code'] ?? ($zone?->code); @endphp

{{ $order->user->name }}

@if($deliveryAddress)

{{ $deliveryAddress }}

@endif @if($order->user->city)

{{ $order->user->city->name }}, Colombia

@endif @if($order->user->phone || $order->user->mobile_phone)

{{ $order->user->phone ?? $order->user->mobile_phone }}

@endif @if($order->user->email)

{{ $order->user->email }}

@endif
@if($deliveryZone || $deliveryRoute || $deliveryCode)

Información de Rutero

@if($deliveryZone)

Zona

{{ $deliveryZone }}

@endif @if($deliveryRoute)

Ruta

{{ $deliveryRoute }}

@endif @if($deliveryCode)

Rutero

{{ $deliveryCode }}

@endif
@endif
Volver a Comprar
@endsection