Fixes issue #8

This commit is contained in:
Christopher Neugebauer 2016-03-31 19:13:31 +11:00
parent 5e0c87c435
commit 8b79670608

View file

@ -188,7 +188,10 @@ def handle_products(request, category, products, prefix):
@transaction.atomic
def set_quantities_from_products_form(products_form, current_cart):
for product_id, quantity, field_name in products_form.product_quantities():
# TODO: issue #8 is a problem here.
quantities = list(products_form.product_quantities())
quantities.sort(key=lambda item: item[1])
for product_id, quantity, field_name in quantities:
product = rego.Product.objects.get(pk=product_id)
try:
current_cart.set_quantity(product, quantity, batched=True)