CancelGuestOrderMutation
Description
Cancels a specific order for a guest user. This mutation allows guest users to cancel their orders by providing their email address, order number, and a cancellation reason.
Endpoint
mutation cancelGuestOrder($comment: String!, $email: String!, $number: String!) {
cancelGuestOrder(comment: $comment, email: $email, number: $number) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| comment | String | Yes | The reason for canceling the order. This will be recorded in the order history. |
| String | Yes | The email address associated with the order. This is used to verify that the user has permission to cancel the order. | |
| number | String | Yes | The order number (increment_id) of the order to cancel. |
Return Values
The mutation returns a PurchaseType object with the following fields:
| Field | Type | Description |
|---|---|---|
| success | Boolean | Indicates whether the order was successfully canceled. |
| order_number | String | The order number of the canceled order. |
Usage Example
mutation {
cancelGuestOrder(
comment: "Changed my mind about this purchase",
email: "customer@example.com",
number: "ORD-12345"
) {
success
order_number
}
}
Example Response
{
"data": {
"cancelGuestOrder": {
"success": true,
"order_number": "ORD-12345"
}
}
}
Notes
- This mutation is specifically for guest users who don't have an account. For logged-in customers, use the
cancelOrdermutation instead. - The order must exist and match both the provided email address and order number.
- If the order is already canceled, an error will be thrown with the message "The order was already canceled."
- If the order cannot be canceled for any reason, an error will be thrown with the message "The order could not be canceled."
- Depending on the store's configuration, canceling an order may trigger additional actions such as restoring inventory, refunding payments, or sending notification emails.
- The comment provided will be recorded in the order history and may be visible to store administrators.