Skip to main content

Problems

During processing checkout, some problems might occur. Some of them would need to be solved before placing the order. Saleor aggregates existing checkout problems:

Each problem may require different actions from the customer.

info

Not all potential problems are already ported to problems field. See the list below. The list of supported problems will be extended in future releases.

Checkout.problems​

Checkout.problems contains the list of all problems that occurred for the checkout. It also includes the problems that are related to specific lines.

The example below shows query that fetches a Checkout.problems.

query checkout($id: ID) {
checkout(id: $id) {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
... on CheckoutLineProblemVariantNotAvailable {
line {
id
}
}
... on CheckoutProblemDeliveryMethodStale {
delivery {
id
shippingMethod {
id
name
}
}
}
... on CheckoutProblemDeliveryMethodInvalid {
delivery {
id
shippingMethod {
id
name
}
}
}
}
}
}

CheckoutLine.problems​

CheckoutLine.problems contains the list of problems that are strictly related to the specific checkout line. The list of problems will be also attached to Checkout.problems field.

The example below shows query that fetches a CheckoutLine.problems.

query checkout($id: ID) {
checkout(id: $id) {
id
lines {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
... on CheckoutLineProblemVariantNotAvailable {
line {
id
}
}
}
}
}
}

Problem types​

CheckoutLineProblemInsufficientStock​

CheckoutLineProblemInsufficientStock - defines the problem where there is not enough stock for the quantity assigned to CheckoutLine. Until resolving the problem, placing the order will not be possible. Mutation for finalizing the checkout like checkoutComplete will return an error INSUFFICIENT_STOCK. The quantity should be reduced to the value that is less or equal to CheckoutLineProblemInsufficientStock.availableQuantity.

query checkout($id: ID) {
checkout(id: $id) {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
}
lines {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
}
}
}
}

CheckoutLineProblemVariantNotAvailable​

CheckoutLineProblemVariantNotAvailable - defines the problem where the attached variant to CheckoutLine is not available for purchase. Until resolving the problem, placing the order will not be possible. Mutation for finalizing the checkout like checkoutComplete will return one of the errors: PRODUCT_NOT_PUBLISHED, PRODUCT_UNAVAILABLE_FOR_PURCHASE, UNAVAILABLE_VARIANT_IN_CHANNEL.

query checkout($id: ID) {
checkout(id: $id) {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
... on CheckoutLineProblemVariantNotAvailable {
line {
id
}
}
}
lines {
id
problems {
__typename
... on CheckoutLineProblemInsufficientStock {
availableQuantity
variant {
id
}
line {
id
}
}
... on CheckoutLineProblemVariantNotAvailable {
line {
id
}
}
}
}
}
}

CheckoutProblemDeliveryMethodStale​

Added in Saleor 3.23.

CheckoutProblemDeliveryMethodStale - indicates that the assigned delivery method's pricing or availability may be outdated. This happens after changes that affect shipping (e.g. voucher applied, shipping address updated, line quantity changed). The method is still assigned but has not been re-validated.

To solve, call deliveryOptionsCalculate. If the method is still valid, the problem clears. If the method is no longer available, the problem becomes CheckoutProblemDeliveryMethodInvalid.

info

This problem does not block checkout completion but when CheckoutProblemDeliveryMethodStale is present while calling checkoutComplete mutation, Saleor will implicitly validate the delivery. If assigned delivery is invalid, checkout complete will return an error.

CheckoutProblemDeliveryMethodInvalid​

Added in Saleor 3.23.

CheckoutProblemDeliveryMethodInvalid - indicates that the assigned delivery method is no longer applicable (e.g. it was deleted, or it no longer ships to the checkout address).

To solve, call deliveryOptionsCalculate to get a list of available methods, then call checkoutDeliveryMethodUpdate with a valid method ID.

info

This problem blocks checkout completion. checkoutComplete will return an error until a valid delivery method is selected.

Control error flow​

In the current way of error handling, some mutations can raise an error that is not related to the requested action. For example, checkoutShippingAddressUpdate can raise INSUFFICIENT_STOCK error. It is raised as some of the ProductVariants attached to Checkout don't have enough stock to finalize the checkout process. By changing the value of the flag useLegacyErrorFlow to false, the errors unrelated to specific actions will not be raised (as in the above example: mutation checkoutShippingAddressUpdate was raising INSUFFICIENT_STOCK error). Instead, the new problem will be listed as Checkout.problems and CheckoutLine.problems (if the problem is related to the CheckoutLine).

caution

Not all potential problems are already ported to the problems field. See the list above. It means that even by switching useLegacyErrorFlow to false, some mutations can raise the error unrelated to the requested action. The list of supported problems will be extended in future releases.

note

The flag useLegacyErrorFlow can be modified by updating the checkoutSettings via channelUpdate mutation.

The flag useLegacyErrorFlow can be also changed via Saleor-dashboard side.