Skip to content

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

Replace is_shipping_required on model with is_shipping_required utils method when it can be done

IKarbowiak75ae56e096c9
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index 5ce779a14c..3b2fc7aeae 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -628,7 +628,8 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):
}
)
- if not checkout.is_shipping_required():
+ lines = fetch_checkout_lines(checkout)
+ if not is_shipping_required(lines):
raise ValidationError(
{
"shipping_address": ValidationError(
@@ -641,9 +642,8 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):
shipping_address = cls.validate_address(
shipping_address, instance=checkout.shipping_address, info=info
)
- discounts = info.context.discounts
- lines = fetch_checkout_lines(checkout)
+ discounts = info.context.discounts
checkout_info = fetch_checkout_info(checkout, lines, discounts)
country = get_user_country_context(
diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.py
index bebfa7ebde..f262dabe88 100644
--- a/saleor/plugins/avatax/__init__.py
+++ b/saleor/plugins/avatax/__init__.py
@@ -14,6 +14,7 @@ from django.core.cache import cache
from requests.auth import HTTPBasicAuth
from ...checkout import base_calculations
+from ...checkout.utils import is_shipping_required
from ...core.taxes import TaxError
from ...order.utils import get_total_order_discount
@@ -157,7 +158,7 @@ def _validate_checkout(
return False
shipping_address = checkout_info.shipping_address
- shipping_required = checkout_info.checkout.is_shipping_required()
+ shipping_required = is_shipping_required(lines)
address = shipping_address or checkout_info.billing_address
return _validate_adddress_details(
shipping_address, shipping_required, address, checkout_info.shipping_method