Skip to content

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

Add Checkout.delivery and new delivery related CheckoutProblems (#18565)

Maciej Korycinski92f6b3670e4d
diff --git a/saleor/checkout/problems.py b/saleor/checkout/problems.py
index 80d8850923..7cd962351e 100644
--- a/saleor/checkout/problems.py
+++ b/saleor/checkout/problems.py
@@ -7,7 +7,7 @@ from ..graphql.core.context import ChannelContext
from ..product.models import ProductChannelListing, ProductVariant
from ..warehouse.models import Stock
from .fetch import CheckoutInfo, CheckoutLineInfo
-from .models import CheckoutLine
+from .models import Checkout, CheckoutDelivery, CheckoutLine
@dataclass
@@ -22,11 +22,24 @@ class CheckoutLineProblemVariantNotAvailable:
line: CheckoutLine
+@dataclass
+class CheckoutProblemDeliveryMethodStale:
+ delivery: CheckoutDelivery
+
+
+@dataclass
+class CheckoutProblemDeliveryMethodInvalid:
+ delivery: CheckoutDelivery
+
+
CHECKOUT_LINE_PROBLEM_TYPE = (
CheckoutLineProblemInsufficientStock | CheckoutLineProblemVariantNotAvailable
)
CHECKOUT_PROBLEM_TYPE = (
- CheckoutLineProblemInsufficientStock | CheckoutLineProblemVariantNotAvailable
+ CheckoutLineProblemInsufficientStock
+ | CheckoutLineProblemVariantNotAvailable
+ | CheckoutProblemDeliveryMethodStale
+ | CheckoutProblemDeliveryMethodInvalid
)
VARIANT_ID = int
@@ -179,6 +192,8 @@ def get_checkout_lines_problems(
def get_checkout_problems(
+ checkout: Checkout,
+ assigned_delivery: CheckoutDelivery | None,
checkout_lines_problem: dict[
CHECKOUT_LINE_PK_TYPE, list[CHECKOUT_LINE_PROBLEM_TYPE]
],
@@ -190,7 +205,22 @@ def get_checkout_problems(
The stocks need to have annotated available_quantity field.
"""
- problems = []
+ problems: list[CHECKOUT_PROBLEM_TYPE] = []
for line_problems in checkout_lines_problem.values():
problems.extend(line_problems)
+
+ if assigned_delivery is None:
+ return problems
+
+ if (
+ checkout.delivery_methods_stale_at
+ and checkout.delivery_methods_stale_at < datetime.datetime.now(tz=datetime.UTC)
+ ):
+ problems.append(CheckoutProblemDeliveryMethodStale(delivery=assigned_delivery))
+
+ if assigned_delivery and not assigned_delivery.is_valid:
+ problems.append(
+ CheckoutProblemDeliveryMethodInvalid(delivery=assigned_delivery)
+ )
+
return problems
diff --git a/saleor/graphql/checkout/dataloaders/problems.py b/saleor/graphql/checkout/dataloaders/problems.py
index 42aa7d7cdc..a2691ba048 100644
--- a/saleor/graphql/checkout/dataloaders/problems.py
+++ b/saleor/graphql/checkout/dataloaders/problems.py
@@ -3,6 +3,7 @@ from collections.abc import Iterable
from promise import Promise
+from ....checkout.models import CheckoutDelivery
from ....checkout.problems import (
CHANNEL_SLUG,
CHECKOUT_LINE_PROBLEM_TYPE,
@@ -22,10 +23,12 @@ from ...product.dataloaders import (
from ...warehouse.dataloaders import (
StocksWithAvailableQuantityByProductVariantIdCountryCodeAndChannelLoader,
)
+from .checkout_delivery import CheckoutDeliveryByIdLoader
from .checkout_infos import (
CheckoutInfoByCheckoutTokenLoader,
CheckoutLinesInfoByCheckoutTokenLoader,
)
+from .models import CheckoutByTokenLoader
class CheckoutLinesProblemsByCheckoutIdLoader(
@@ -139,19 +142,51 @@ class CheckoutProblemsByCheckoutIdDataloader(
context_key = "checkout_problems_by_checkout_id"
def batch_load(self, keys):
- line_problems_dataloader = CheckoutLinesProblemsByCheckoutIdLoader(self.context)
-
- def _resolve_problems(
- checkouts_lines_problems: list[dict[str, list[CHECKOUT_LINE_PROBLEM_TYPE]]],
- ):
- checkout_problems = defaultdict(list)
- for checkout_pk, checkout_lines_problems in zip(
- keys, checkouts_lines_problems, strict=False
+ def _with_assigned_delivery(checkouts):
+ def _resolve_problems(
+ data: tuple[
+ list[dict[str, list[CHECKOUT_LINE_PROBLEM_TYPE]]],
+ list[CheckoutDelivery | None],
+ ],
):
- checkout_problems[checkout_pk] = get_checkout_problems(
- checkout_lines_problems
- )
+ checkouts_lines_problems, checkouts_deliveries = data
+ checkout_problems = defaultdict(list)
+ checkout_delivery_map = {
+ delivery.pk: delivery
+ for delivery in checkouts_deliveries
+ if delivery
+ }
+ for checkout_lines_problems, checkout in zip(
+ checkouts_lines_problems,
+ checkouts,
+ strict=False,
+ ):
+ checkout_problems[checkout.pk] = get_checkout_problems(
+ checkout,
+ checkout_delivery_map.get(checkout.assigned_delivery_id),
+ checkout_lines_problems,
+ )
- return [checkout_problems.get(key, []) for key in keys]
+ return [checkout_problems.get(key, []) for key in keys]
+
+ assigned_delivery_ids = [
+ checkout.assigned_delivery_id
+ for checkout in checkouts
+ if checkout.assigned_delivery_id
+ ]
+ checkout_delivery_dataloader = CheckoutDeliveryByIdLoader(self.context)
+ line_problems_dataloader = CheckoutLinesProblemsByCheckoutIdLoader(
+ self.context
+ )
+ return Promise.all(
+ [
+ line_problems_dataloader.load_many(keys),
+ checkout_delivery_dataloader.load_many(assigned_delivery_ids),
+ ]
+ ).then(_resolve_problems)
- return line_problems_dataloader.load_many(keys).then(_resolve_problems)
+ return (
+ CheckoutByTokenLoader(self.context)
+ .load_many(keys)
+ .then(_with_assigned_delivery)
+ )
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index e960c808f1..5ead92d29b 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -5204,3 +5204,198 @@ def test_query_checkout_shipping_method_dont_invalidate_taxes_when_nothing_chang
assert content["data"]["checkout"]["shippingMethod"]["id"] == to_global_id_or_none(
shipping_method
)
+
+
+def test_checkout_delivery_returns_external_shipping_methods(
+ user_api_client, checkout_with_delivery_method_for_external_shipping
+):
+ # given
+ checkout = checkout_with_delivery_method_for_external_shipping
+ delivery = checkout.assigned_delivery
+
+ query = """
+ query getCheckout($id: ID) {
+ checkout(id: $id) {
+ delivery {
+ id
+ shippingMethod {
+ id
+ name
+ }
+ }
+ }
+ }
+ """
+ variables = {"id": to_global_id_or_none(checkout)}
+
+ # when
+ response = user_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["checkout"]["delivery"]
+ assert data is not None
+ assert data["id"] == to_global_id_or_none(delivery)
+ assert data["shippingMethod"]["name"] == delivery.name
+
+
+def test_checkout_delivery_returns_built_in_shipping_methods(
+ user_api_client, checkout_with_item, checkout_delivery, shipping_method, address
+):
+ # given
+ checkout = checkout_with_item
+ checkout.shipping_address = address
+ checkout.assigned_delivery = checkout_delivery(checkout, shipping_method)
+ checkout.save()
+
+ delivery = checkout.assigned_delivery
+
+ query = """
+ query getCheckout($id: ID) {
+ checkout(id: $id) {
+ delivery {
+ id
+ shippingMethod {
+ id
+ name
+ }
+ }
+ }
+ }
+ """
+ variables = {"id": to_global_id_or_none(checkout)}
+
+ # when
+ response = user_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["checkout"]["delivery"]
+ assert data is not None
+ assert data["id"] == to_global_id_or_none(delivery)
+ assert data["shippingMethod"]["name"] == shipping_method.name
+
+
+def test_checkout_delivery_returns_none_when_no_delivery_assigned(
+ user_api_client, checkout_with_item
+):
+ # given
+ checkout = checkout_with_item
+ assert checkout.assigned_delivery_id is None
+
+ query = """
+ query getCheckout($id: ID) {
+ checkout(id: $id) {
+ delivery {
+ id
+ shippingMethod {
+ id
+ name
+ }
+ }
+ }
+ }
+ """
+ variables = {"id": to_global_id_or_none(checkout)}
+
+ # when
+ response = user_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["delivery"] is None
+
+
[email protected]_time("2023-01-01 12:00:00")
+ "saleor.plugins.webhook.plugin.WebhookPlugin.get_shipping_methods_for_checkout"
+)
+@override_settings(PLUGINS=["saleor.plugins.webhook.plugin.WebhookPlugin"])
+def test_checkout_delivery_do_not_trigger_any_webhook_calls(
+ mocked_shipping_webhook_fetch,
+ user_api_client,
+ checkout_with_item,
+ checkout_delivery,
+ shipping_method,
+ address,
+):
+ # given
+ checkout = checkout_with_item
+ checkout.shipping_address = address
+ checkout.assigned_delivery = checkout_delivery(checkout, shipping_method)
+ checkout.delivery_methods_stale_at = timezone.now()
+ checkout.save()
+
+ query = """
+ query getCheckout($id: ID) {
+ checkout(id: $id) {
+ delivery {
+ id
+ shippingMethod {
+ id
+ name
+ }
+ }
+ }
+ }
+ """
+ variables = {"id": to_global_id_or_none(checkout)}
+
+ # when
+ response = user_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["delivery"] is not None
+ # Ensure no webhook was triggered
+ mocked_shipping_webhook_fetch.assert_not_called()
+
+
+ "saleor.plugins.webhook.plugin.WebhookPlugin.get_shipping_methods_for_checkout"
+)
+def test_checkout_delivery_returns_shipping_when_marked_as_invalid(
+ mocked_shipping_webhook_fetch,
+ user_api_client,
+ checkout_with_item,
+ checkout_delivery,
+ shipping_method,
+ address,
+):
+ # given
+ checkout = checkout_with_item
+ checkout.shipping_address = address
+ checkout.assigned_delivery = checkout_delivery(checkout, shipping_method)
+ checkout.save()
+
+ delivery = checkout.assigned_delivery
+ # Mark the delivery as invalid
+ delivery.is_valid = False
+ delivery.save(update_fields=["is_valid"])
+
+ query = """
+ query getCheckout($id: ID) {
+ checkout(id: $id) {
+ delivery {
+ id
+ shippingMethod {
+ id
+ name
+ }
+ }
+ }
+ }
+ """
+ variables = {"id": to_global_id_or_none(checkout)}
+
+ # when
+ response = user_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["checkout"]["delivery"]
+ # The delivery field should still return the delivery object even when marked as invalid
+ assert data is not None
+ assert data["id"] == to_global_id_or_none(delivery)
+ assert data["shippingMethod"]["name"] == shipping_method.name
+ mocked_shipping_webhook_fetch.assert_not_called()
diff --git a/saleor/graphql/checkout/tests/test_checkout_problems.py b/saleor/graphql/checkout/tests/test_checkout_problems.py
index 5b81fccc84..f8d50b164d 100644
--- a/saleor/graphql/checkout/tests/test_checkout_problems.py
+++ b/saleor/graphql/checkout/tests/test_checkout_problems.py
@@ -1,6 +1,7 @@
import datetime
from django.utils import timezone
+from freezegun import freeze_time
from ....product.models import ProductChannelListing, ProductVariantChannelListing
from ....warehouse.models import Allocation, Reservation
@@ -27,6 +28,18 @@ query checkout($id: ID) {
id
}
}
+ ... on CheckoutProblemDeliveryMethodStale{
+ __typename
+ delivery {
+ id
+ }
+ }
+ ... on CheckoutProblemDeliveryMethodInvalid{
+ __typename
+ delivery {
+ id
+ }
+ }
}
}
}
@@ -421,3 +434,108 @@ def test_checkout_problems_when_variant_channel_listing_doesnt_have_price_amount
assert content["data"]["checkout"]["problems"][0]["line"][
"id"
] == to_global_id_or_none(checkout_line)
+
+
+@freeze_time("2024-05-31 12:00:01")
+def test_checkout_problems_delivery_method_stale(
+ checkout_with_items_and_shipping, api_client
+):
+ # given
+ checkout = checkout_with_items_and_shipping
+ checkout.delivery_methods_stale_at = timezone.now() - datetime.timedelta(minutes=5)
+ checkout.save(update_fields=["delivery_methods_stale_at"])
+
+ checkout_id = to_global_id_or_none(checkout)
+ variables = {"id": checkout_id, "channel": checkout.channel.slug}
+
+ # when
+ response = api_client.post_graphql(QUERY_CHECKOUT_WITH_PROBLEMS, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["id"] == checkout_id
+ assert len(content["data"]["checkout"]["problems"]) == 1
+ problem = content["data"]["checkout"]["problems"][0]
+ assert problem["__typename"] == "CheckoutProblemDeliveryMethodStale"
+ assert problem["delivery"]["id"] == to_global_id_or_none(checkout.assigned_delivery)
+
+
+@freeze_time("2024-05-31 12:00:01")
+def test_checkout_problems_delivery_method_invalid(
+ checkout_with_items_and_shipping, api_client
+):
+ # given
+ checkout = checkout_with_items_and_shipping
+ checkout.assigned_delivery.is_valid = False
+ checkout.assigned_delivery.save(update_fields=["is_valid"])
+
+ checkout_id = to_global_id_or_none(checkout)
+ variables = {"id": checkout_id, "channel": checkout.channel.slug}
+
+ # when
+ response = api_client.post_graphql(QUERY_CHECKOUT_WITH_PROBLEMS, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["id"] == checkout_id
+ assert len(content["data"]["checkout"]["problems"]) == 1
+ problem = content["data"]["checkout"]["problems"][0]
+ assert problem["__typename"] == "CheckoutProblemDeliveryMethodInvalid"
+ assert problem["delivery"]["id"] == to_global_id_or_none(checkout.assigned_delivery)
+
+
+@freeze_time("2024-05-31 12:00:01")
+def test_checkout_problems_delivery_method_stale_and_invalid(
+ checkout_with_items_and_shipping, api_client
+):
+ # given
+ checkout = checkout_with_items_and_shipping
+ checkout.assigned_delivery.is_valid = False
+ checkout.assigned_delivery.save(
+ update_fields=[
+ "is_valid",
+ ]
+ )
+ checkout.delivery_methods_stale_at = timezone.now() - datetime.timedelta(minutes=5)
+ checkout.save(update_fields=["delivery_methods_stale_at"])
+
+ checkout_id = to_global_id_or_none(checkout)
+ variables = {"id": checkout_id, "channel": checkout.channel.slug}
+
+ # when
+ response = api_client.post_graphql(QUERY_CHECKOUT_WITH_PROBLEMS, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["id"] == checkout_id
+ assert len(content["data"]["checkout"]["problems"]) == 2
+ problems = content["data"]["checkout"]["problems"]
+ problem_types = [problem["__typename"] for problem in problems]
+ assert "CheckoutProblemDeliveryMethodStale" in problem_types
+ assert "CheckoutProblemDeliveryMethodInvalid" in problem_types
+
+ assigned_delivery_id = to_global_id_or_none(checkout.assigned_delivery)
+ assert problems[0]["delivery"]["id"] == assigned_delivery_id
+ assert problems[1]["delivery"]["id"] == assigned_delivery_id
+
+
+@freeze_time("2024-05-31 12:00:01")
+def test_checkout_problems_without_delivery_method(
+ checkout_with_items_and_shipping, api_client
+):
+ # given
+ checkout = checkout_with_items_and_shipping
+ checkout.assigned_delivery = None
+ checkout.delivery_methods_stale_at = timezone.now() - datetime.timedelta(minutes=5)
+ checkout.save(update_fields=["delivery_methods_stale_at", "assigned_delivery"])
+
+ checkout_id = to_global_id_or_none(checkout)
+ variables = {"id": checkout_id, "channel": checkout.channel.slug}
+
+ # when
+ response = api_client.post_graphql(QUERY_CHECKOUT_WITH_PROBLEMS, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["checkout"]["id"] == checkout_id
+ assert len(content["data"]["checkout"]["problems"]) == 0
diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.py
index 7c2bab4682..9b36e4ae46 100644
--- a/saleor/graphql/checkout/types.py
+++ b/saleor/graphql/checkout/types.py
@@ -48,6 +48,7 @@ from ..core.descriptions import (
ADDED_IN_318,
ADDED_IN_319,
ADDED_IN_321,
+ ADDED_IN_323,
PREVIEW_FEATURE,
)
from ..core.doc_category import DOC_CATEGORY_CHECKOUT
@@ -241,6 +242,30 @@ def _resolve_line_problem_type(
return None
+class CheckoutProblemDeliveryMethodStale(
+ SyncWebhookControlContextObjectType[problems.CheckoutProblemDeliveryMethodStale]
+):
+ delivery = graphene.Field("saleor.graphql.checkout.types.Delivery", required=True)
+
+ class Meta:
+ default_resolver = SyncWebhookControlContextObjectType.resolver_with_context
+ description = "Indicates that the delivery methods are stale." + ADDED_IN_323
+ doc_category = DOC_CATEGORY_CHECKOUT
+
+
+class CheckoutProblemDeliveryMethodInvalid(
+ SyncWebhookControlContextObjectType[problems.CheckoutProblemDeliveryMethodInvalid]
+):
+ delivery = graphene.Field("saleor.graphql.checkout.types.Delivery", required=True)
+
+ class Meta:
+ default_resolver = SyncWebhookControlContextObjectType.resolver_with_context
+ description = (
+ "Indicates that the selected delivery method is invalid." + ADDED_IN_323
+ )
+ doc_category = DOC_CATEGORY_CHECKOUT
+
+
class CheckoutLineProblem(graphene.Union):
class Meta:
types = (
@@ -264,7 +289,10 @@ class CheckoutLineProblem(graphene.Union):
class CheckoutProblem(graphene.Union):
class Meta:
- types = [] + list(CheckoutLineProblem._meta.types)
+ types = [
+ CheckoutProblemDeliveryMethodStale,
+ CheckoutProblemDeliveryMethodInvalid,
+ ] + list(CheckoutLineProblem._meta.types)
description = "Represents an problem in the checkout."
doc_category = DOC_CATEGORY_CHECKOUT
@@ -277,6 +305,13 @@ class CheckoutProblem(graphene.Union):
line_problem_type = _resolve_line_problem_type(instance)
if line_problem_type:
return line_problem_type
+
+ problem_instance = instance.node
+ if isinstance(problem_instance, problems.CheckoutProblemDeliveryMethodStale):
+ return CheckoutProblemDeliveryMethodStale
+ if isinstance(problem_instance, problems.CheckoutProblemDeliveryMethodInvalid):
+ return CheckoutProblemDeliveryMethodInvalid
+
return super().resolve_type(instance.node, info)
@@ -626,6 +661,26 @@ class DeliveryMethod(graphene.Union):
return super().resolve_type(instance, info)
+class Delivery(graphene.ObjectType):
+ id = graphene.ID(required=True, description="The ID of the delivery.")
+ shipping_method = graphene.Field(
+ ShippingMethod,
+ description="Shipping method represented by the delivery.",
+ )
+
+ class Meta:
+ description = "Represents a delivery option for the checkout." + ADDED_IN_323
+ doc_category = DOC_CATEGORY_CHECKOUT
+
+ def resolve_id(root: models.CheckoutDelivery, info: ResolveInfo) -> str:
+ return graphene.Node.to_global_id("CheckoutDelivery", root.pk)
+
+ def resolve_shipping_method(
+ root: models.CheckoutDelivery, _info: ResolveInfo
+ ) -> ShippingMethodData | None:
+ return convert_checkout_delivery_to_shipping_method_data(root)
+
+
def _should_load_denormalized_checkout_deliveries(
checkout_context: SyncWebhookControlContext[models.Checkout],
):
@@ -926,10 +981,15 @@ class Checkout(SyncWebhookControlContextModelObjectType[models.Checkout]):
),
],
)
+ delivery = BaseField(
+ Delivery,
+ description="The delivery method selected for this checkout." + ADDED_IN_323,
+ )
+
shipping_method = BaseField(
ShippingMethod,
description="The shipping method related with checkout.",
- deprecation_reason="Use `deliveryMethod` instead.",
+ deprecation_reason="Use `delivery` instead.",
webhook_events_info=[
WebhookEventInfo(
type=WebhookEventSyncType.SHIPPING_LIST_METHODS_FOR_CHECKOUT,
@@ -950,6 +1010,7 @@ class Checkout(SyncWebhookControlContextModelObjectType[models.Checkout]):
delivery_method = BaseField(
DeliveryMethod,
description="The delivery method selected for this checkout.",
+ deprecation_reason="Use `delivery` instead.",
webhook_events_info=[
WebhookEventInfo(
type=WebhookEventSyncType.SHIPPING_LIST_METHODS_FOR_CHECKOUT,
@@ -1155,6 +1216,17 @@ class Checkout(SyncWebhookControlContextModelObjectType[models.Checkout]):
return _resolve_checkout_delivery(root, info)
+ @staticmethod
+ def resolve_delivery(
+ root: SyncWebhookControlContext[models.Checkout], info: ResolveInfo
+ ):
+ if not root.node.assigned_delivery_id:
+ return None
+
+ return CheckoutDeliveryByIdLoader(info.context).load(
+ root.node.assigned_delivery_id
+ )
+
@staticmethod
def resolve_quantity(
root: SyncWebhookControlContext[models.Checkout], info: ResolveInfo
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 71142c608e..60b43eb1eb 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -10619,6 +10619,13 @@ type Checkout implements Node & ObjectWithMetadata @doc(category: "Checkout") {
"""
shippingPrice: TaxedMoney! @webhookEventsInfo(asyncEvents: [], syncEvents: [CHECKOUT_CALCULATE_TAXES])
+ """
+ The delivery method selected for this checkout.
+
+ Added in Saleor 3.23.
+ """
+ delivery: Delivery
+
"""
The shipping method related with checkout.
@@ -10626,7 +10633,7 @@ type Checkout implements Node & ObjectWithMetadata @doc(category: "Checkout") {
- SHIPPING_LIST_METHODS_FOR_CHECKOUT (sync): Optionally triggered when cached external shipping methods are invalid.
- CHECKOUT_FILTER_SHIPPING_METHODS (sync): Optionally triggered when cached filtered shipping methods are invalid.
"""
- shippingMethod: ShippingMethod @webhookEventsInfo(asyncEvents: [], syncEvents: [SHIPPING_LIST_METHODS_FOR_CHECKOUT, CHECKOUT_FILTER_SHIPPING_METHODS]) @deprecated(reason: "Use `deliveryMethod` instead.")
+ shippingMethod: ShippingMethod @webhookEventsInfo(asyncEvents: [], syncEvents: [SHIPPING_LIST_METHODS_FOR_CHECKOUT, CHECKOUT_FILTER_SHIPPING_METHODS]) @deprecated(reason: "Use `delivery` instead.")
"""
The delivery method selected for this checkout.
@@ -10635,7 +10642,7 @@ type Checkout implements Node & ObjectWithMetadata @doc(category: "Checkout") {
- SHIPPING_LIST_METHODS_FOR_CHECKOUT (sync): Optionally triggered when cached external shipping methods are invalid.
- CHECKOUT_FILTER_SHIPPING_METHODS (sync): Optionally triggered when cached filtered shipping methods are invalid.
"""
- deliveryMethod: DeliveryMethod @webhookEventsInfo(asyncEvents: [], syncEvents: [SHIPPING_LIST_METHODS_FOR_CHECKOUT, CHECKOUT_FILTER_SHIPPING_METHODS])
+ deliveryMethod: DeliveryMethod @webhookEventsInfo(asyncEvents: [], syncEvents: [SHIPPING_LIST_METHODS_FOR_CHECKOUT, CHECKOUT_FILTER_SHIPPING_METHODS]) @deprecated(reason: "Use `delivery` instead.")
"""
The price of the checkout before shipping, with taxes included.
@@ -11034,6 +11041,19 @@ type CheckoutLineProblemVariantNotAvailable @doc(category: "Checkout") {
line: CheckoutLine!
}
+"""
+Represents a delivery option for the checkout.
+
+Added in Saleor 3.23.
+"""
+type Delivery {
+ """The ID of the delivery."""
+ id: ID!
+
+ """Shipping method represented by the delivery."""
+ shippingMethod: ShippingMethod
+}
+
"""
Represents a delivery method chosen for the checkout. `Warehouse` type is used when checkout is marked as "click and collect" and `ShippingMethod` otherwise.
"""
@@ -12740,7 +12760,25 @@ enum TokenizedPaymentFlowEnum @doc(category: "Payments") {
}
"""Represents an problem in the checkout."""
-union CheckoutProblem = CheckoutLineProblemInsufficientStock | CheckoutLineProblemVariantNotAvailable
+union CheckoutProblem = CheckoutProblemDeliveryMethodStale | CheckoutProblemDeliveryMethodInvalid | CheckoutLineProblemInsufficientStock | CheckoutLineProblemVariantNotAvailable
+
+"""
+Indicates that the delivery methods are stale.
+
+Added in Saleor 3.23.
+"""
+type CheckoutProblemDeliveryMethodStale @doc(category: "Checkout") {
+ delivery: Delivery!
+}
+
+"""
+Indicates that the selected delivery method is invalid.
+
+Added in Saleor 3.23.
+"""
+type CheckoutProblemDeliveryMethodInvalid @doc(category: "Checkout") {
+ delivery: Delivery!
+}
type CheckoutCountableConnection @doc(category: "Checkout") {
"""Pagination data for this connection."""