mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-22 08:08:04 +01:00
Fix unpriced item deletion
This commit is contained in:
parent
56c2c7045d
commit
f3cd4201b2
2 changed files with 8 additions and 3 deletions
|
@ -14,7 +14,7 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">{{ product.name }}</h4>
|
<h4 class="card-title">{{ product.name }}</h4>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="unpriced_product-{{ product.pk }}" min="0" class="numberinput form-control" required="" id="unpriced_id_product-{{ product.pk }}"
|
<input type="number" step="1" name="unpriced_product-{{ product.pk }}" min="0" class="numberinput form-control" required="" id="unpriced_id_product-{{ product.pk }}"
|
||||||
value="{{ value|default:0 }}"
|
value="{{ value|default:0 }}"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -49,8 +49,13 @@ def update_with_unpriced_products(basket: Basket, post_data: MultiValueDict):
|
||||||
basket.items.filter(product__in=no_fixed_price.values()).delete()
|
basket.items.filter(product__in=no_fixed_price.values()).delete()
|
||||||
for product_id, product in no_fixed_price.items():
|
for product_id, product in no_fixed_price.items():
|
||||||
if prices := post_data.getlist(f"{UNPRICED_PREFIX}{product_id}"):
|
if prices := post_data.getlist(f"{UNPRICED_PREFIX}{product_id}"):
|
||||||
for price in prices:
|
for price in map(int, prices):
|
||||||
basket.items.create(product=product, quantity=1, unit_price_cents=price)
|
if price:
|
||||||
|
basket.items.create(
|
||||||
|
product=product,
|
||||||
|
quantity=1,
|
||||||
|
unit_price_cents=price,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@require_http_methods(["GET", "POST"])
|
@require_http_methods(["GET", "POST"])
|
||||||
|
|
Loading…
Reference in a new issue