Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fixed variant list in cls.process_checkout_lines (#11070)
Joshua Cender8b14aaf855b5
diff --git a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.pyindex a76a1593da..03c180c45a 100644--- a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py+++ b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py@@ -16,7 +16,6 @@ from ....checkout.utils import (is_shipping_required,)from ....core.tracing import traced_atomic_transaction-from ....product import models as product_modelsfrom ....warehouse.reservations import is_reservation_enabledfrom ...account.i18n import I18nMixinfrom ...account.types import AddressInput@@ -90,13 +89,11 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):channel_slug: str,delivery_method_info: "DeliveryMethodBase",) -> None:- variant_ids = [line_info.variant.id for line_info in lines]- variants = list(- product_models.ProductVariant.objects.filter(- id__in=variant_ids- ).prefetch_related("product__product_type")- ) # FIXME: is this prefetch needed?- quantities = [line_info.line.quantity for line_info in lines]+ variants = []+ quantities = []+ for line_info in lines:+ variants.append(line_info.variant)+ quantities.append(line_info.line.quantity)site = get_site_promise(info.context).get()check_lines_quantity(variants,diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_address_update.py b/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_address_update.pyindex be01c35557..caa4175642 100644--- a/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_address_update.py+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_address_update.py@@ -204,6 +204,47 @@ def test_checkout_shipping_address_update_insufficient_stocks(assert checkout.last_change == previous_last_change+ "saleor.graphql.checkout.mutations.checkout_shipping_address_update."+ "update_checkout_shipping_method_if_invalid",+ wraps=update_checkout_shipping_method_if_invalid,+)+@override_settings(DEFAULT_COUNTRY="DE")+def test_checkout_shipping_address_update_doesnt_raise_error(+ mocked_update_shipping_method,+ channel_USD,+ user_api_client,+ product_list,+ graphql_address_data,+):+ variant_a = product_list[0].variants.first()+ variant_b = product_list[1].variants.first()+ Stock.objects.filter(product_variant=variant_a).update(quantity=4)+ Stock.objects.filter(product_variant=variant_b).update(quantity=1)+ checkout = Checkout.objects.create(channel=channel_USD, currency="USD")+ checkout.set_country("PL", commit=True)+ checkout_info = fetch_checkout_info(checkout, [], [], get_plugins_manager())+ add_variant_to_checkout(checkout_info, variant_b, 1)+ add_variant_to_checkout(checkout_info, variant_a, 4)+ assert checkout.shipping_address is None++ shipping_address = graphql_address_data+ shipping_address["country"] = "US"+ shipping_address["countryArea"] = "New York"+ shipping_address["postalCode"] = "10001"+ variables = {+ "id": to_global_id_or_none(checkout),+ "shippingAddress": shipping_address,+ }++ response = user_api_client.post_graphql(+ MUTATION_CHECKOUT_SHIPPING_ADDRESS_UPDATE, variables+ )+ content = get_graphql_content(response)+ data = content["data"]["checkoutShippingAddressUpdate"]+ assert not data["errors"]++@mock.patch("saleor.graphql.checkout.mutations.checkout_shipping_address_update.""update_checkout_shipping_method_if_invalid",