Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix updating invalid shipping method on checkout
fowczareka663af69b0d8
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex f0e65e9b26..3686fbcf53 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -81,18 +81,13 @@ def clean_shipping_method(def update_checkout_shipping_method_if_invalid(checkout: models.Checkout, discounts):# remove shipping method when empty checkout- if checkout.quantity == 0:+ if checkout.quantity == 0 or not checkout.is_shipping_required():checkout.shipping_method = Nonecheckout.save(update_fields=["shipping_method"])- is_valid = True- try:- is_valid = clean_shipping_method(- checkout=checkout, method=checkout.shipping_method, discounts=discounts- )- except ValidationError:- checkout.shipping_method = None- checkout.save(update_fields=["shipping_method"])+ is_valid = clean_shipping_method(+ checkout=checkout, method=checkout.shipping_method, discounts=discounts+ )if not is_valid:cheapest_alternative = get_valid_shipping_methods_for_checkout(@@ -340,7 +335,6 @@ class CheckoutLinesAdd(BaseMutation):quantities = [line.get("quantity") for line in lines]check_lines_quantity(variants, quantities)- # update_checkout_shipping_method_if_invalid(checkout, info.context.discounts)if variants and quantities:for variant, quantity in zip(variants, quantities):