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:

  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

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": []
    }
  }
}