@extends('layouts.page') @section('head') @include('elements.seo', [ 'title'=>'Carrito de compras', 'description'=> 'Carrito de compras' ]) @endsection @section('content') @php // Define delivery settings variables at top level for use throughout the view $forceDeliveryDateEnabled = \App\Models\Setting::getByKey('force_delivery_date_enabled'); $isForceEnabled = ($forceDeliveryDateEnabled === '1' || $forceDeliveryDateEnabled === 1 || $forceDeliveryDateEnabled === true); $isEnabled = \App\Models\Setting::isExpress48hEnabled(); @endphp @if($set_user)
{{ Aire::open()->route('seller.setclient')}}
{{ Aire::input('document', 'Documento Cliente: Escribe el NIT sin dígito de verificación')->groupClass('mb-0') }}

La zona se asigna automaticamente usando la zona del vendedor.

Ingresar
{{ Aire::close() }}
@else
{{-- Toast Notifications (via JS) --}} @if($alertVendors) @endif @if($vendorDiscountAlerts) @endif @if($alertTotal) @endif @if(session('coupon_removed_message')) @endif {{-- Page Title --}}

Tu Carrito

{{-- ============================================= --}} {{-- CARD 1: Products, Coupon & Total --}} {{-- ============================================= --}}
{{-- Products Header --}}

Productos ({{ count($products) }} {{ count($products) == 1 ? 'artículo' : 'artículos' }})

{{-- Products List --}}
@foreach ($products as $key => $product)
{{-- Mobile Layout --}}
{{-- Product Info Row --}}
{{ $product->name }}
slug)}}' class="font-medium text-sm text-gray-900 hover:text-orange-600 transition-colors block"> {{$product->name}} @if($product->variation) {{$product->variation->name}} {{$product->item->name}} @endif ${{currency($product->calculatedFinalPrice['old'])}}
{{-- Delete Button --}}
{{-- Quantity & Price Row --}}
{{-- Quantity Controls --}}
{{-- Price --}}
${{currency($product->calculatedFinalPrice['price'] * $product->quantity)}} @if($product->calculatedFinalPrice['has_discount']) ${{currency($product->calculatedFinalPrice['old'] * $product->quantity)}} @endif
{{-- Desktop Layout --}}
@endforeach
@if(!empty($bonificationPreview))

Bonificaciones aplicables

@foreach($bonificationPreview as $preview)

{{ $preview['bonification_name'] }}: @if(!empty($preview['gift_product_name'])) obtienes {{ $preview['gift_quantity'] }} {{ $preview['gift_quantity'] === 1 ? 'unidad' : 'unidades' }} de {{ $preview['gift_product_name'] }}. @else obtienes {{ $preview['gift_quantity'] }} {{ $preview['gift_quantity'] === 1 ? 'unidad' : 'unidades' }} de obsequio. @endif

Producto que activa: {{ $preview['trigger_product_name'] }}. Regla: compra {{ $preview['buy'] }}, recibe {{ $preview['get'] }}. Cantidad acumulada en carrito: {{ $preview['aggregated_items'] }}.

@endforeach
@endif {{-- Coupon Section --}}

Cupón de descuento

@if($appliedCoupon && !empty($appliedCoupon['coupons'])) {{-- Show each applied coupon with individual remove button --}}
@foreach($appliedCoupon['coupons'] as $couponEntry)
{{$couponEntry['coupon_code']}}
@csrf
@endforeach
Total descuento por cupones: -${{currency($appliedCoupon['discount_amount'])}}
@elseif($appliedCoupon) {{-- Legacy single coupon display --}}
{{$appliedCoupon['coupon_code']}} -${{currency($appliedCoupon['discount_amount'])}} de descuento
@csrf
@endif {{-- Always show the coupon input form to allow adding more coupons --}}
@csrf
{{-- Totals Section --}}
@php $subtotal = $products->sum(function($product){ return $product->calculatedFinalPrice['old'] * $product->quantity; }); $totalAfterDiscounts = $products->sum(function($product){ return $product->calculatedFinalPrice['price'] * $product->quantity; }); $totalDiscount = $subtotal - $totalAfterDiscounts; $couponDiscountAmount = $appliedCoupon ? ($appliedCoupon['discount_amount'] ?? 0) : 0; $discount = max(0, $totalDiscount - $couponDiscountAmount); $shippingAmount = 0; $finalTotal = $totalAfterDiscounts + $shippingAmount; @endphp
Subtotal ${{currency($subtotal)}}
Descuento -${{currency($discount)}}
@if($appliedCoupon && $appliedCoupon['discount_amount'] > 0)
Cupón ({{$appliedCoupon['coupon_code']}}) -${{currency($appliedCoupon['discount_amount'])}}
@endif @if(!empty($cartRetentions['rules_for_js']))
Retenciones ({{ $cartRetentions['tax_group'] }}) — estimado según reglas activas
Retención en la fuente -${{currency($cartRetentions['retention_fuente'] ?? 0)}}
Retención de IVA -${{currency($cartRetentions['retention_iva'] ?? 0)}}
@endif
Total productos ${{currency($finalTotal)}}

El flete y el total a pagar se confirman al elegir el método de envío.

{{-- ============================================= --}} {{-- CARD 2: Order Details & Checkout --}} {{-- ============================================= --}}
{{-- Section Header --}}

Resumen del pedido

{{-- Client Info (if seller with client) --}} @if($client)
Cliente {{$client->name}}
{{ Aire::open()->route('seller.removeclient')->class('inline')}} {{ Aire::close() }}
@endif @if($alertVendors || $alertTotal) {{-- Disabled state - show message --}}

Revisa los mensajes de alerta para poder continuar con tu pedido.

@else {{ Aire::open()->route('cart.process')}}
{{-- Address Selection --}}
{{-- Delivery Method Selection --}} @if($shippingMethods->isNotEmpty())
@php $expressFreeShippingMin = \App\Models\Setting::expressFreeShippingMinimum(); $expressFreeShippingEnabled = \App\Models\Setting::isExpressFreeShippingEnabled(); $freeShippingMessage = \App\Models\Setting::getByKey('free_shipping_message'); @endphp
@foreach($shippingMethods as $method) @php $isExpress = $method->code === 'express'; $displayName = $isExpress ? 'Entrega Especial' : 'Entrega Standard'; $displayDescription = $isExpress ? 'Realiza tu pedido de lunes a viernes antes de las 5:00 pm para recibir en 48 horas. Sábado y domingo realiza pedido las 24 horas y recíbelo en 48 horas del siguiente día hábil. Aplica para ciudades principales.' : 'Envío gratis.'; @endphp @endforeach
@else

No hay métodos de envío disponibles en este momento. Por favor contacta al administrador.

@endif {{-- Observations --}}
{{-- Payable total (includes freight after method selection) --}}
Flete $0 GRATIS
Total a pagar ${{currency($finalTotal)}}
{{-- Submit Button --}}
{{ Aire::close() }} @endif
@endif @endsection @section('scripts') @endsection