Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix updating cart lines quantity with removing lines
Anna Siwik2d198427298c
diff --git a/saleor/cart/utils.py b/saleor/cart/utils.pyindex 48f5b6be98..98cce038cb 100644--- a/saleor/cart/utils.py+++ b/saleor/cart/utils.py@@ -58,9 +58,6 @@ def remove_unavailable_variants(cart):except InsufficientStock as e:quantity = e.item.get_stock_quantity()cart.add(line.variant, quantity=quantity, replace=True)- finally:- if quantity > 0:- line.refresh_from_db()def get_product_variants_and_prices(cart, product):diff --git a/saleor/cart/views.py b/saleor/cart/views.pyindex f877e80477..d9232801f0 100644--- a/saleor/cart/views.py+++ b/saleor/cart/views.py@@ -23,6 +23,12 @@ def index(request, cart):cart_lines = []check_product_availability_and_warn(request, cart)+ # refresh required to get updated cart lines and it's quantity+ try:+ cart = Cart.objects.get(pk=cart.pk)+ except Cart.DoesNotExist:+ pass+for line in cart.lines.all():initial = {'quantity': line.get_quantity()}form = ReplaceCartLineForm(None, cart=cart, variant=line.variant,