Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Remove shipping method when empty checkout

fowczarek67c19364b925
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index 161cc8ea87..7b35d6ed8b 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -77,6 +77,11 @@ 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:
+ checkout.shipping_method = None
+ checkout.save(update_fields=["shipping_method"])
+
is_valid = clean_shipping_method(
checkout=checkout, method=checkout.shipping_method, discounts=discounts
)