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

29 lines
1.1 KiB
HTML

{% load i18n %}
<form action="" hx-post="{% url 'web:add_cart_item' %}" hx-swap="none">
{% csrf_token %}
<input type="hidden" name="product" value="{{ product.pk }}">
{% if product.has_variants %}
<div class="mb-4">
<label for="variant">{% translate 'Variante' %}</label>
<select class="input" id="variant" name="variant">
{% for variant in product.variants.all %}
<option value="{{ variant.pk }}" {% if not variant.stock %}disabled{% endif %}>
{% for attribute_value in variant.attribute_values.all %}{{ attribute_value }}{% if not forloop.last %}, {% endif %}{% endfor %}
{% if not variant.stock %}({% translate 'agotado' %}){% endif %}
</option>
{% endfor %}
</select>
</div>
{% endif %}
<div class="flex items-center">
<input class="input mr-4" id="quantity" aria-label="quantity" type="number" min="1" max="10" name="quantity" value="1">
<button class="btn btn-primary">
{% include 'components/icons/add_cart.svg' %}
{% translate 'Añadir al carrito' %}
</button>
</div>
</form>