Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Ensure that only methods available in given channels are returned from applicable_shipping_methods
IKarbowiak9d4747cb7f34
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex 3760107398..4e24e91f58 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -1331,6 +1331,22 @@ def test_checkout_available_shipping_methods_weight_method_with_higher_minimal_wassert shipping_method.name not in shipping_methods+def test_checkout_available_shipping_methods_shipping_zone_without_channels(+ api_client, checkout_with_item, address, shipping_zone+):+ shipping_zone.channels.clear()+ checkout_with_item.shipping_address = address+ checkout_with_item.save()++ query = GET_CHECKOUT_AVAILABLE_SHIPPING_METHODS+ variables = {"token": checkout_with_item.token}+ response = api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ data = content["data"]["checkout"]++ assert len(data["availableShippingMethods"]) == 0++def test_checkout_available_shipping_methods_excluded_postal_codes(api_client, checkout_with_item, address, shipping_zone):diff --git a/saleor/graphql/order/tests/test_order.py b/saleor/graphql/order/tests/test_order.pyindex 2e6167eaad..bbacca44dd 100644--- a/saleor/graphql/order/tests/test_order.py+++ b/saleor/graphql/order/tests/test_order.py@@ -486,8 +486,10 @@ def test_order_query_in_pln_channel(staff_api_client,permission_manage_orders,order_with_lines_channel_PLN,+ shipping_zone,channel_PLN,):+ shipping_zone.channels.add(channel_PLN)order = order_with_lines_channel_PLNstaff_api_client.user.user_permissions.add(permission_manage_orders)response = staff_api_client.post_graphql(ORDERS_QUERY)diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 1f45ede6ee..d37e3849e9 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -123,6 +123,7 @@ class ShippingMethodQueryset(models.QuerySet):"""qs = self.filter(shipping_zone__countries__contains=country_code,+ shipping_zone__channels__id=channel_id,channel_listings__currency=price.currency,channel_listings__channel_id=channel_id,)diff --git a/saleor/shipping/tests/test_shipping.py b/saleor/shipping/tests/test_shipping.pyindex f617b53133..f54ae9e2ac 100644--- a/saleor/shipping/tests/test_shipping.py+++ b/saleor/shipping/tests/test_shipping.py@@ -265,6 +265,7 @@ def test_use_default_shipping_zone(shipping_zone, channel_USD):default_zone.countries = get_countries_without_shipping_zone()default_zone.save(update_fields=["countries"])+ default_zone.channels.add(channel_USD)weight_method = default_zone.shipping_methods.create(minimum_order_weight=Weight(kg=1),maximum_order_weight=Weight(kg=10),