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 %}
|
||||
{% block content %}
|
||||
{% 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">
|
||||
{{ basket.created_at }}
|
||||
</p>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<div class="alert alert-danger" role="alert">{% translate "Missing payment method." %}</div>
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
{% crispy form %}
|
||||
<div class="row">
|
||||
|
|
|
@ -129,4 +129,7 @@ def price_preview(request: WSGIRequest) -> HttpResponse:
|
|||
elif name.startswith(UNPRICED_PREFIX):
|
||||
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