completeOrder mutation
data-variant=info
data-slots=text
This mutation is available automatically on Adobe Commerce as a Cloud Service. On Adobe Commerce on Cloud and on-premises instances, you must install Payment Services for Adobe Commerce 2.10.0 or higher to use this 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:
- A cart has been created (guest or logged-in customer).
- Products have been added to the cart.
- Billing and shipping addresses have been set, if applicable.
- A shipping method has been selected (for physical products).
- A payment or checkout ID has been generated and is available.
- For guest carts, a valid email address has been assigned.
Limitations
- The
completeOrdermutation is similar to theplaceOrdermutation, but includes an additional required fieldidto capture the payment identifier. - On success, the mutation returns the
orderV2object containing thenumberandtokenfields. - The
tokenfield allows guest users to retrieve their order using queries such asguestOrderByToken.
Syntax
mutation {
completeOrder(
input: CompleteOrderInput
) {
CompleteOrderOutput
}
}
Reference
The completeOrder reference provides detailed information about the types and fields defined in this mutation.
Example usage
Request:
mutation {
completeOrder(input: {
cartId: "AJCY8dhIfuch9LcDHAxEkw7oG3DjGdKt"
id: "88455624KT013492F"
}) {
orderV2 {
number
token
}
errors {
message
code
}
}
}
Response:
{
"data": {
"completeOrder": {
"orderV2": {
"number": "0000000012",
"token": "0:3:OSScWU6PKLn3kFyMhNWyskG0opgVvFBnJmtuaFHKGwDFT83S6Kv9U39iYwixuU+vhwDz2AF4pCs3GtLhHbQ="
},
"errors": []
}
}
}