@extends('layouts.page') @section('head') @include('elements.seo', [ 'title'=>'Carrito de compras', 'description'=> 'Carrito de compras' ]) @endsection @section('content') @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') }} {{ Aire::input('zone', 'Zona Sucursal: Diligencia este campo si tu cliente cuenta con varias sucursales')->helpText('*En el siguiente paso verás las direcciones asociadas')->groupClass('mb-0') }}
Ingresar
{{ Aire::close() }}
@else
@if($client) {{ Aire::open()->route('seller.removeclient')}}
{{$client->name}}
{{ Aire::close() }} @endif
@if($alertVendors)
@foreach ($alertVendors as $alert) @endforeach
@endif @if($vendorDiscountAlerts)
@foreach ($vendorDiscountAlerts as $alert) @endforeach
@endif
@if($alertVendors)
@foreach ($alertVendors as $alert) @endforeach
@endif @if($alertTotal)
@endif
{{ Aire::open()->route('cart.update')}}

Productos

@foreach ($products as $key => $product)
slug)}}'>{{$product->name}}
${{currency($product->calculatedFinalPrice['old'])}} @if($product->variation) {{$product->variation->name}} {{$product->item->name}} @endif
{{-- --}}
@if($has_orders) ${{currency($product->calculatedFinalPrice['old'] * $product->quantity)}} @else ${{currency($product->calculatedFinalPrice['price'] * $product->quantity)}} @endif @if($product->calculatedFinalPrice['has_discount'] && !$has_orders) ${{currency($product->calculatedFinalPrice['old'] * $product->quantity)}} @endif
@endforeach
{{ Aire::close() }}
@if($appliedCoupon)
Cupón aplicado: {{$appliedCoupon['coupon_code']}}
Descuento: ${{currency($appliedCoupon['discount_amount'])}}
@csrf
@else
@csrf
@endif

@php // Calculate subtotal using the original prices $subtotal = $products->sum(function($product){ return $product->calculatedFinalPrice['old'] * $product->quantity; }); // Calculate the total after all discounts are applied // (this is what the user will actually pay) $totalAfterDiscounts = $products->sum(function($product){ return $product->calculatedFinalPrice['price'] * $product->quantity; }); // For display purposes: // - If no coupon: show all discounts in the "Descuento" line // - If coupon: the coupon is shown separately, so "Descuento" shows non-coupon discounts // But since calculatedFinalPrice already includes all discounts (including coupon), // we just calculate the total discount as the difference if(!$has_orders) { // If there's a coupon, we want to show it separately // So we calculate: discount = (subtotal - totalAfterDiscounts) - couponDiscount // This way "Descuento" shows regular discounts, and coupon shows separately $totalDiscount = $subtotal - $totalAfterDiscounts; $couponDiscountAmount = $appliedCoupon ? ($appliedCoupon['discount_amount'] ?? 0) : 0; // If there's a coupon, subtract it from total discount to avoid double-counting // since we'll show it on a separate line $discount = $appliedCoupon ? ($totalDiscount - $couponDiscountAmount) : $totalDiscount; } else{ $discount = 0; } @endphp
Subtotal ${{currency($subtotal)}}
@if($discount)
Descuento -${{currency($discount)}}
@endif @if($appliedCoupon && $appliedCoupon['discount_amount'] > 0)
Descuento cupón ({{$appliedCoupon['coupon_code']}}) -${{currency($appliedCoupon['discount_amount'])}}
@endif
@php // The final total is already calculated with all discounts applied $finalTotal = $totalAfterDiscounts; @endphp
Total ${{currency($finalTotal)}}
@if($alertVendors || $alertTotal)
@else {{ Aire::open()->route('cart.process')}}
{{ Aire::select($zones, 'zone_id', 'Dirección')->id('states')->value(session('zone_id'))}} {{ Aire::select([ 'express' => 'Envío Express', 'tronex' => 'Envío Tronex' ], 'delivery_method', 'Método de Envío') ->id('delivery_method') ->value('tronex') }}
Envío Tronex

Entrega en la próxima ruta asignada (Calculando...)

{{Aire::textarea('observations', 'Observaciones')->placeholder('Información adicional')->rows(3)}}
{{ Aire::close() }} @endif
@endif @endsection @section('scripts') @endsection