setCartAsInactive mutation
This mutation is available only if you have installed Payment Services for Adobe Commerce 2.12.0 or higher.
The setCartAsInactive
mutation sets a specific cartId
as inactive. Use this mutation when a payment error occurs, or when a shopper cancels a payment flow, after the addProductsToNewCart
mutation returns a cartId
. This mutation helps prevent a customer having multiple active carts created with the addProductsToNewCart
mutation.
See the addProductsToNewCart
mutation use case for more information about a common workflow for the setCartAsInactive
mutation.
Syntax
Copied to your clipboardmutation {setCartAsInactive(cartId: String!): SetCartAsInactiveOutput}
Example usage
The following examples show responses to the setCartAsInactive
mutation.
Request:
Copied to your clipboardmutation {setCartAsInactive(cartId: "gVFVNBSJPt7L6uCQis4Q1ryj6DQtcwM2") {successerror}}
Set cart as inactive (success)
The following response example shows what the mutation returns when setCartAsInactive
is successful, and no error.
Response:
Copied to your clipboard{"data": {"setCartAsInactive": {"success": true,"error": null}}}
Set cart as inactive (failure)
The following example response indicates the mutation failed due to a non-existent cartId
.
Response:
Copied to your clipboard{"data": {"setCartAsInactive": {"success": false,"error": "Error when setting the cart gVFVNBSJPt7L6uCQis4Q1ryj6QtcwM2 as inactive - No such entity with cartId = null "}}}