Files
shoppy/web/templates/components/cart/cart.html
T
2026-07-23 11:37:37 +02:00

353 lines
16 KiB
HTML

{% load i18n %}
<section class=" py-2 antialiased md:py-8">
<form action="{% url 'web:cart_detail' %}" method="post">
{% csrf_token %}
<div class="mx-auto max-w-screen-xl px-4 2xl:px-0">
<h2 class="text-xl font-semibold sm:text-2xl">{% translate 'Carrito' %}</h2>
<div class="mt-4 sm:mt-6 md:gap-6 lg:flex lg:items-start xl:gap-8">
<div class="mx-auto w-full flex-none lg:max-w-2xl xl:max-w-4xl">
<div class="space-y-6">
{% for item in items %}
<div class="rounded-lg p-4 shadow-md md:p-6">
<div class="space-y-4 flex items-center justify-between gap-6 space-y-0">
<a href="{% url 'web:product_detail' pk=item.product.pk slug=item.product.slug %}"
class="shrink-0 md:order-1">
<img class="h-20 w-20" src="{{ item.product.images.all.0.s.url }}"
alt="{{ item.product.name }}"/>
<img class="hidden h-20 w-20" src="{{ item.product.images.all.0.s_dark.url }}"
alt="{{ item.product.name }}"/>
</a>
<div class="w-full min-w-0 flex-1 space-y-4 md:order-2 md:max-w-md">
<a href="{% url 'web:product_detail' pk=item.product.pk slug=item.product.slug %}"
class="text-base font-medium hover:underline "
>
{{ item.product.name }}
</a>
{% if item.variant %}
<p class="text-sm">
{% for attribute_value in item.variant.attribute_values.all %}{{ attribute_value }}{% if not forloop.last %}, {% endif %}{% endfor %}
</p>
{% endif %}
<div class="flex items-center gap-4">
<form class="flex" hx-post="{% url 'web:delete_cart_item' pk=item.pk %}"
hx-swap="none">
{% csrf_token %}
<button
type="submit"
class="inline-flex items-center text-sm font-medium text-red-700 hover:underline cursor-pointer"
>
{% include 'components/icons/x.svg' %}
{% translate 'Quitar' %}
</button>
</form>
</div>
</div>
<label for="counter-input" class="sr-only">{% translate 'Cantidad' %}</label>
<div class="flex items-center justify-between md:order-3 md:justify-end">
<div class="flex items-center">
<span class="w-10 shrink-0 text-center text-sm font-medium focus:outline-none focus:ring-0">
{{ item.quantity }}x
</span>
</div>
<div class="text-end md:order-4 md:w-32">
<p class="text-base font-bold ">
{{ item.price.price_with_tax }}€
</p>
</div>
</div>
</div>
</div>
{% endfor %}
{% if items.count == 0 %}
<p class="text-base font-normal ">
{% translate 'No hay nada en el carrito...' %}
</p>
<p>
<a href="{% url 'web:index' %}" title=""
class="inline-flex items-center gap-2 text-sm font-medium text-primary-700 underline hover:no-underline ">
{% translate 'Volver a inicio' %}
</a>
</p>
{% endif %}
<h2 class="text-xl font-semibold sm:text-2xl">
{% translate 'Dirección de envío' %}
</h2>
<section class="p-4 rounded-lg">
<div class="grid gap-4 sm:grid-cols-2 sm:gap-6 my-2">
{% if user.is_anonymous %}
<div class="sm:col-span-2">
<label for="email"
class="block mb-2 text-sm font-medium ">
{% translate 'E-Mail' %}</label>
<input type="text" name="email" id="email"
class="input"
placeholder="{% translate 'E-Mail' %}"
value=""
required=""
>
</div>
{% else %}
<input type="hidden" name="email" value="{{ user.email }}">
{% endif %}
<div class="sm:col-span-2">
<label for="shipping_address_full_name"
class="block mb-2 text-sm font-medium ">
{% translate 'Nombre completo' %}</label>
<input type="text" name="shipping_address_full_name" id="shipping_address_full_name"
class="input"
placeholder="{% translate 'Nombre completo' %}"
value="{% if shipping_address %}{{ shipping_address.full_name }}{% endif %}"
required=""
>
<label for="shipping_address"
class="block my-2 text-sm font-medium ">
{% translate 'Dirección' %}</label>
<input type="text" name="shipping_address" id="shipping_address"
class="input"
placeholder="{% translate 'Dirección' %}"
value="{% if shipping_address %}{{ shipping_address.address }}{% endif %}"
required=""
>
</div>
<div class="w-full">
<label for="shipping_address_town"
class="block mb-2 text-sm font-medium ">
{% translate 'Localidad' %}
</label>
<input type="text" name="shipping_address_town" id="shipping_address_town"
class="input"
placeholder="{% translate 'Localidad' %}"
value="{% if shipping_address %}{{ shipping_address.address_town }}{% endif %}"
required=""
>
</div>
<div class="w-full">
<label for="shipping_address_zip"
class="block mb-2 text-sm font-medium ">
{% translate 'Código postal' %}
</label>
<input type="text" name="shipping_address_zip" id="shipping_address_zip"
class="input"
placeholder="{% translate 'Código postal' %}"
value="{% if shipping_address %}{{ shipping_address.address_zip }}{% endif %}"
required=""
>
</div>
<div>
<label for="shipping_address_state"
class="block mb-2 text-sm font-medium ">
{% translate 'Provincia' %}
</label>
<input type="text" name="shipping_address_state" id="shipping_address_state"
class="input"
placeholder="{% translate 'Provincia' %}"
value="{% if shipping_address %}{{ shipping_address.address_state }}{% endif %}"
required=""
>
</div>
<div>
<label for="shipping_address_country" class="block mb-2 text-sm font-medium ">
{% translate 'País' %}
</label>
<input type="text" name="shipping_address_country" id="shipping_address_country"
class="input"
placeholder="{% translate 'País' %}"
value="{% if shipping_address %}{{ shipping_address.address_country }}{% endif %}"
required=""
>
</div>
</div>
</section>
<h2 class="text-xl font-semibold sm:text-2xl">
{% translate 'Dirección de facturación' %}
</h2>
<section class="p-4 rounded-lg">
<div class="grid gap-4 sm:grid-cols-2 sm:gap-6 my-2">
<div class="sm:col-span-2">
<label for="billing_address_full_name"
class="block mb-2 text-sm font-medium ">
{% translate 'Nombre completo' %}</label>
<input type="text" name="billing_address_full_name" id="billing_address_full_name"
class="input"
placeholder="{% translate 'Nombre completo' %}"
value="{% if billing_address %}{{ billing_address.full_name }}{% endif %}"
required=""
>
<label for="billing_address"
class="block my-2 text-sm font-medium ">
{% translate 'Dirección' %}
</label>
<input type="text" name="billing_address" id="billing_address"
class="input"
placeholder="{% translate 'Dirección' %}"
value="{% if billing_address %}{{ billing_address.address }}{% endif %}"
required=""
>
</div>
<div class="w-full">
<label for="billing_address_town"
class="block mb-2 text-sm font-medium ">
{% translate 'Localidad' %}
</label>
<input type="text" name="billing_address_town" id="billing_address_town"
class="input"
placeholder="{% translate 'Localidad' %}"
value="{% if billing_address %}{{ billing_address.address_town }}{% endif %}"
required=""
>
</div>
<div class="w-full">
<label for="billing_address_zip"
class="block mb-2 text-sm font-medium ">
{% translate 'Código postal' %}
</label>
<input type="text" name="billing_address_zip" id="billing_address_zip"
class="input"
placeholder="{% translate 'Código postal' %}"
value="{% if billing_address %}{{ billing_address.address_zip }}{% endif %}"
required=""
>
</div>
<div>
<label for="billing_address_state"
class="block mb-2 text-sm font-medium ">
{% translate 'Provincia' %}
</label>
<input type="text" name="billing_address_state" id="billing_address_state"
class="input"
placeholder="{% translate 'Provincia' %}"
value="{% if billing_address %}{{ billing_address.address_state }}{% endif %}"
required=""
>
</div>
<div>
<label for="billing_address_country"
class="block mb-2 text-sm font-medium ">
{% translate 'País' %}
</label>
<input type="text" name="billing_address_country" id="billing_address_country"
class="input"
placeholder="{% translate 'País' %}"
value="{% if billing_address %}{{ billing_address.address_country }}{% endif %}"
required=""
>
</div>
</div>
</section>
<section>
<h2 class="text-xl mb-4 font-semibold sm:text-2xl">
{% translate 'Opciones de envío' %}
</h2>
<article class="rounded-lg">
{% for shipping_method in shipping_methods %}
<div class="p-4">
<input type="radio" id="shipping_method_{{ shipping_method.pk }}"
name="shipping_method"
value="{{ shipping_method.pk }}" {% if forloop.first %}checked{% endif %}>
<label for="shipping_method_{{ shipping_method.pk }}"
class=" ">
{{ shipping_method.name }} - {{ shipping_method.shipping_product.price.price_with_tax }}€
</label>
{% if not forloop.last %}
</div>
<hr class="h-px mx-4"/>
{% endif %}
{% endfor %}
</article>
</section>
</div>
</div>
<!-- Resumen del pedido -->
<div class="mx-auto mt-6 max-w-4xl flex-1 space-y-6 lg:mt-0 lg:w-full">
<div
class="space-y-4 rounded-lg p-4 shadow-md sm:p-6">
<p class="text-xl font-semibold ">
{% translate 'Resumen del pedido' %}
</p>
<div class="space-y-4">
<div class="space-y-2">
<dl class="flex items-center justify-between gap-4">
<dt
class="text-base font-normal ">
{% translate 'Base imponible' %}
</dt>
<dd class="text-base font-medium ">{{ base_total }} €
</dd>
</dl>
<dl class="flex items-center justify-between gap-4">
<dt class="text-base font-normal ">
{% translate 'Descuentos' %}
</dt>
<dd class="text-base font-medium text-green-600">-{{ savings }} €</dd>
</dl>
<dl class="flex items-center justify-between gap-4">
<dt class="text-base font-normal">
{% translate 'Gastos de envío' %}
</dt>
<dd class="text-base font-medium ">
{{ shipping_cost }} €
</dd>
</dl>
<dl class="flex items-center justify-between gap-4">
<dt class="text-base font-normal ">
{% translate 'Impuestos' %}
</dt>
<dd class="text-base font-medium ">{{ tax_total }} €
</dd>
</dl>
</div>
<dl class="flex items-center justify-between gap-4 pt-2 ">
<dt class="text-base font-bold ">{% translate 'Total' %}
</dt>
<dd class="text-base font-bold ">{{ total }} €</dd>
</dl>
</div>
<div class="flex justify-center items-center">
<button
class="btn btn-primary">
{% translate 'Terminar pedido' %}
</button>
</div>
<div class="flex items-center justify-center gap-2">
<span class="text-sm font-normal "> {% translate 'o' %} </span>
<a href="{% url 'web:index' %}" title=""
class="inline-flex items-center gap-2 text-sm font-medium text-primary-700 underline hover:no-underline ">
{% translate 'Seguir comprando' %}
</a>
</div>
</div>
</div>
</div>
</div>
</form>
</section>