checkout/src/purchase/templates/purchase/basket_form.html

68 lines
2.5 KiB
HTML
Raw Normal View History

2022-04-24 18:59:04 +02:00
{% extends "common/base.html" %}
2023-03-27 16:45:00 +02:00
{% load i18n static crispy_forms_tags purchase django_htmx %}
2022-04-28 18:34:13 +02:00
{% block extrahead %}
<link rel="stylesheet" href="{% static "purchase/css/basket_form.css" %}">
{% endblock %}
2022-04-24 18:59:04 +02:00
{% block content %}
2022-05-05 19:19:54 +02:00
{% if basket %}
2023-03-27 17:57:46 +02:00
<h1>{{ basket }} <span id="basket-price" class="badge bg-secondary">{{ basket.price|currency }}</span></h1>
2022-04-25 19:54:57 +02:00
<p class="metadata">
2022-05-05 19:19:54 +02:00
{{ basket.created_at }}
2022-04-25 19:54:57 +02:00
</p>
2022-05-05 19:19:54 +02:00
{% if not basket.payment_method %}
2022-04-25 23:04:49 +02:00
<div class="alert alert-danger" role="alert">{% translate "Missing payment method." %}</div>
{% endif %}
2022-04-24 18:59:04 +02:00
{% else %}
2023-03-27 17:57:46 +02:00
<h1>{% translate "New basket" %} <span id="basket-price" class="badge bg-secondary d-none">{{ basket.price|currency }}</span></h1>
2022-04-24 18:59:04 +02:00
{% endif %}
{% crispy form %}
2023-03-27 16:57:38 +02:00
<div class="row">
<div class="col">
<form
hx-get="{% url "purchase:additional_unpriced_product" %}"
hx-target="#products"
hx-swap="beforeend"
2023-03-27 16:45:00 +02:00
>
2023-03-27 16:57:38 +02:00
<div class="input-group">
<select class="form-select" name="product_to_add" id="product_to_add">
{% for product in products %}
<option value="{{ product.pk }}">{{ product.name }}</option>
{% endfor %}
</select>
<button
class="btn btn-outline-secondary"
type="submit"
id="add_product"
>
{% translate "Add product" %}
</button>
</div>
</form>
2023-03-27 16:45:00 +02:00
</div>
2023-03-27 16:57:38 +02:00
</div>
2023-03-27 16:45:00 +02:00
{% for item in basket.items.all %}
{% if item.product.unit_price_cents == 0 %}
<input
type="hidden"
hx-get="{% url "purchase:additional_unpriced_product" %}?product_to_add={{ item.product.pk }}&value={{ item.unit_price_cents }}"
hx-trigger="load"
hx-target="#products"
hx-swap="beforeend"
>
{% endif %}
{% endfor %}
2023-03-27 16:57:38 +02:00
<div class="row mt-4">
<div class="col">
{% if basket %}
<a href="{% url "purchase:new" %}" class="btn btn-secondary">{% translate "New basket" %}</a>
{% endif %}
</div>
</div>
2022-04-24 18:59:04 +02:00
{% endblock %}
2023-03-27 16:45:00 +02:00
{% block extrascript %}
<script src="{% static 'vendor/htmx-1.8.6/htmx.min.js' %}" defer></script>
{% django_htmx_script %}
{% endblock %}