Skip to main content
Version: 1.0.0

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

ArgumentTypeRequiredDescription
commentStringYesThe reason for canceling the order. This will be recorded in the order history.
emailStringYesThe email address associated with the order. This is used to verify that the user has permission to cancel the order.
numberStringYesThe order number (increment_id) of the order to cancel.

Return Values

The mutation returns a PurchaseType object with the following fields:

FieldTypeDescription
successBooleanIndicates whether the order was successfully canceled.
order_numberStringThe 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 cancelOrder mutation 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.