@extends('admin.layouts.app') @push('css') @endpush @section('content')

Orden #{{ str_pad($order->id, 6, '0', STR_PAD_LEFT) }}

@include('admin.message') @php // MP es la fuente de verdad para el estado del dinero $mpAcreditado = in_array($order->mp_payment_status, ['approved', 'PAGAD']); $mpRechazado = in_array($order->mp_payment_status, ['rejected', 'cancelled', 'refunded', 'charged_back']); $mpPendiente = $order->mp_payment_status === 'pending' || $order->mp_payment_status === 'in_process'; $mpCancelUser = $order->mp_payment_status === 'cancelled_by_user'; $tieneMP = !empty($order->mp_payment_id) || !empty($order->mp_payment_status); $sinPago = !$tieneMP && $order->payment_status !== 'paid' && !empty($order->payment_method); $mostrarBanner = $order->status === 'cancelled' || $tieneMP || $sinPago || !empty($order->notes); @endphp @if($mostrarBanner) {{-- Banner: eligió método de pago pero nunca completó --}} @if($sinPago)
Sin pago — El cliente generó la orden pero nunca inició el pago
Método elegido: {{ ucfirst($order->payment_method) }}
Monto: ${{ number_format($order->grand_total, 2, ',', '.') }}
Fecha orden: {{ $order->created_at->format('d/m/Y H:i') }}
{{-- Banner principal: estado del dinero según MP --}} @elseif($tieneMP && $mpAcreditado)
Pago Acreditado — La plata ingresó
MP ID: {{ $order->mp_payment_id }}
Monto: ${{ number_format($order->grand_total, 2, ',', '.') }}
@elseif($tieneMP && ($mpRechazado || $mpCancelUser))
Pago NO Acreditado {{ $mpCancelUser ? 'El cliente canceló el pago desde MercadoPago' : 'Rechazado/Devuelto por MercadoPago' }}
@if($order->mp_payment_id)
MP ID: {{ $order->mp_payment_id }}
@endif
MP Status: {{ $order->mp_payment_status }}
@if($order->mp_status_detail)
Detalle: {{ $order->mp_status_detail }}
@endif
@elseif($tieneMP && $mpPendiente)
Pago Pendiente en MercadoPago
@if($order->mp_payment_id)
MP ID: {{ $order->mp_payment_id }}
@endif @if($order->mp_status_detail)
Detalle: {{ $order->mp_status_detail }}
@endif
@endif {{-- Banner secundario: notas/cancelación --}} @if(!empty($order->notes))
{{ $order->status === 'cancelled' ? 'Motivo:' : 'Notas:' }} {{ $order->notes }}
@endif @endif

Orden #{{ str_pad($order->id, 6, '0', STR_PAD_LEFT) }}

{{ \Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') }}

@if ($order->status == 'pending') Pendiente @elseif ($order->status == 'processing') En Proceso @elseif ($order->status == 'shipped') Enviado @elseif ($order->status == 'delivered') Entregado @elseif ($order->status == 'cancelled') Cancelado @else {{ ucfirst($order->status) }} @endif

${{ number_format($order->grand_total, 2) }}

Total de la orden

Productos y Facturación
@foreach( $orderItems as $item ) @endforeach @if($order->discount > 0) @endif
Producto Precio Unit. Cantidad Total
{{ $item->name }}
@if($item->size || $item->color) @if($item->size) Talla: {{ $item->size }} @endif @if($item->color) Color: {{ $item->color }} @endif @endif
${{ number_format($item->price, 2) }} {{ $item->qty }} ${{ number_format($item->total, 2) }}
Subtotal: ${{ number_format($order->subtotal, 2) }}
Descuento @if(!empty($order->coupon_code))({{ $order->coupon_code }})@endif: -${{ number_format($order->discount, 2) }}
Envío: ${{ number_format($order->shipping, 2) }}
TOTAL GENERAL: ${{ number_format($order->grand_total, 2) }}
Información de Envío y Contacto
Dirección de Envío
{{ $order->first_name.' '.$order->last_name }}
{{ $order->address }}
{{ $order->city }}, {{ $order->zip }}
{{ $order->countryName }}

{{ $order->mobile }}
{{ $order->email }}

Fechas Importantes

Fecha de Pedido:
{{ \Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') }}
Fecha de Envío:
@if (!empty($order->shipped_date)) {{ \Carbon\Carbon::parse($order->shipped_date)->format('d/m/Y H:i') }} @else Pendiente @endif
Gestión de la Orden

Actualizar Estado

Selecciona la fecha cuando el pedido fue enviado

Documentos PDF

Selecciona el destinatario del comprobante
@endsection @section('customJs') @endsection