Edit in GitHubLog an issue

completeOrder mutation

The completeOrder mutation synchronizes order details before you run the placeOrder mutation.

When the mutation runs, Commerce generates and returns a token in the orderV2.token field. You can supply the token value to the guestOrderByToken query to retrieve details about an order created by a guest shopper.

Preconditions

Before you run the completeOrder mutation, ensure that:

  1. A cart has been created (guest or logged-in customer).
  2. Products have been added to the cart.
  3. Billing and shipping addresses have been set, if applicable.
  4. A shipping method has been selected (for physical products).
  5. A payment or checkout ID has been generated and is available.
  6. For guest carts, a valid email address has been assigned.

Limitations

  • The completeOrder mutation is similar to the placeOrder mutation, but includes an additional required field id to capture the payment identifier.
  • On success, the mutation returns the orderV2 object containing the number and token fields.
  • The token field allows guest users to retrieve their order using queries such as guestOrderByToken.

Syntax

Copied to your clipboard
mutation {
completeOrder(
input: CompleteOrderInput
) {
CompleteOrderOutput
}
}

Example usage

Request:

Copied to your clipboard
mutation {
completeOrder(input: {
cartId: "AJCY8dhIfuch9LcDHAxEkw7oG3DjGdKt"
id: "88455624KT013492F"
}) {
orderV2 {
number
token
}
errors {
message
code
}
}
}

Response:

Copied to your clipboard
{
"data": {
"completeOrder": {
"orderV2": {
"number": "0000000012",
"token": "0:3:OSScWU6PKLn3kFyMhNWyskG0opgVvFBnJmtuaFHKGwDFT83S6Kv9U39iYwixuU+vhwDz2AF4pCs3GtLhHbQ="
},
"errors": []
}
}
}

Input attributes

CompleteOrderInput

FieldTypeDescription
cartId
String!
The unique identifier of the shopping cart (quote).
id
String!
The payment, checkout, or transaction identifier tied to the order.

Output attributes

CompleteOrderOutput

FieldTypeDescription
errors
Error!
List of error objects. The array is empty if there are no errors.
orderV2
OrderV2
Contains minimal order details if successful.

OrderV2 object

FieldTypeDescription
number
String
The order number assigned by the system.
token
String
A token that can be used to retrieve the order, especially for guest checkouts.

Error object

FieldTypeDescription
code
String
A machine-readable error code.
message
String
A human-readable message describing the error.

Possible error codes

CodeDescription
CART_NOT_FOUND
The provided cart ID does not exist.
CART_NOT_ACTIVE
The cart is not active (already converted or expired).
GUEST_EMAIL_MISSING
A guest cart does not have an email address assigned.
PAYMENT_ID_INVALID
The provided payment or transaction ID is invalid.
UNABLE_TO_COMPLETE_ORDER
A general error occurred while finalizing the order (for example, missing information or out-of-stock items).
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.