mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-22 08:08:04 +01:00
Live update basket price in title
This commit is contained in:
parent
2d952e1a63
commit
a219eeae84
2 changed files with 6 additions and 3 deletions
|
@ -6,7 +6,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if basket %}
|
{% if basket %}
|
||||||
<h1>{{ basket }} <span class="badge bg-secondary">{{ basket.price|currency }}</span></h1>
|
<h1>{{ basket }} <span id="basket-price" class="badge bg-secondary">{{ basket.price|currency }}</span></h1>
|
||||||
<p class="metadata">
|
<p class="metadata">
|
||||||
{{ basket.created_at }}
|
{{ basket.created_at }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<div class="alert alert-danger" role="alert">{% translate "Missing payment method." %}</div>
|
<div class="alert alert-danger" role="alert">{% translate "Missing payment method." %}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1>{% translate "New basket" %}</h1>
|
<h1>{% translate "New basket" %} <span id="basket-price" class="badge bg-secondary d-none">{{ basket.price|currency }}</span></h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% crispy form %}
|
{% crispy form %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -129,4 +129,7 @@ def price_preview(request: WSGIRequest) -> HttpResponse:
|
||||||
elif name.startswith(UNPRICED_PREFIX):
|
elif name.startswith(UNPRICED_PREFIX):
|
||||||
total += sum(map(int, request.POST.getlist(name)))
|
total += sum(map(int, request.POST.getlist(name)))
|
||||||
|
|
||||||
return HttpResponse(f"Montant total : {total/100:.2f}€")
|
total = f"{total/100:.2f}€"
|
||||||
|
return HttpResponse(
|
||||||
|
f'<span hx-swap-oob="true" id="basket-price" class="badge bg-secondary">{total}</span>Montant total : {total}',
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue