Skip to content

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

Validate if shipping method is still valid after changing checkout's content

Pacu2c36fe6dd9b07
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index 4433ffe24d..52afc2f317 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -180,6 +180,16 @@ class CheckoutLinesAdd(BaseMutation):
for variant, quantity in zip(variants, quantities):
add_variant_to_cart(
checkout, variant, quantity, replace=replace)
+ # FIXME test if below function is called
+ clean_shipping_method(
+ checkout=checkout,
+ method=checkout.shipping_method,
+ errors=errors,
+ discounts=info.context.discounts,
+ taxes=get_taxes_for_address(checkout.shipping_address))
+ if errors:
+ CheckoutLinesAdd(errors=errors)
+
return CheckoutLinesAdd(checkout=checkout, errors=errors)
@@ -215,7 +225,18 @@ class CheckoutLineDelete(BaseMutation):
info, line_id, errors, 'line_id', only_type=CheckoutLine)
if line and line in checkout.lines.all():
line.delete()
- return CheckoutLinesAdd(checkout=checkout, errors=errors)
+
+ # FIXME test if below function is called
+ clean_shipping_method(
+ checkout=checkout,
+ method=checkout.shipping_method,
+ errors=errors,
+ discounts=info.context.discounts,
+ taxes=get_taxes_for_address(checkout.shipping_address))
+ if errors:
+ CheckoutLineDelete(errors=errors)
+
+ return CheckoutLineDelete(checkout=checkout, errors=errors)
class CheckoutCustomerAttach(BaseMutation):