Edit in GitHubLog an issue
Thanks to Something Digital (now Rightpoint) for contributing this topic!

setPaymentMethodAndPlaceOrder mutation

The setPaymentMethodAndPlaceOrder mutation sets the cart payment method and converts the cart into an order. The mutation returns the resulting order ID. You cannot manage orders with GraphQL, because orders are part of the backend. You can use REST or SOAP calls to manage orders to their completion.

Perform the following actions before using the setPaymentMethodAndPlaceOrder mutation:

  • Create an empty cart
  • Add one or more products to the cart
  • Set the billing address
  • Set the shipping address (non-virtual carts only)
  • Set the shipping method (non-virtual carts only)
  • For guest customers, assign an email to the cart

Syntax

Copied to your clipboard
mutation {
setPaymentMethodAndPlaceOrder(
input: SetPaymentMethodAndPlaceOrderInput
) {
PlaceOrderOutput
}
}

Reference

The setPaymentMethodAndPlaceOrder reference provides detailed information about the types and fields defined in this mutation.

Example usage

Request:

Copied to your clipboard
mutation {
setPaymentMethodAndPlaceOrder(
input: {
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG"
payment_method: {
code: "checkmo"
}
}
) {
order {
order_id
}
}
}

Response:

Copied to your clipboard
{
"data": {
"setPaymentMethodAndPlaceOrder": {
"order": {
"order_id": "000000006"
}
}
}
}

Errors

ErrorDescription
Could not find a cart with ID "XXX"
The specified cart_id value does not exist in the quote_id_mask table.
Guest email for cart is missing.
The guest attempted to place an order but did not provide an email address. See the setGuestEmailOnCart mutation.
Required parameter "cart_id" is missing
The required cart_id argument contains an empty value.
Required parameter "code" for "payment_method" is missing.
The value specified in the code argument is empty.
The current user cannot perform operations on cart "XXX"
An unauthorized user (guest) tried to set a payment method and place an order with a customer's cart, or an authorized user (customer) tried to set a payment method and place an order with a cart of another customer.
The shipping address is missing. Set the address and try again.
You ran setPaymentMethodAndPlaceOrder mutation before setShippingAddressesOnCart. Set a shipping address first. GraphQL checkout tutorial shows the order placement sequence.
The requested Payment Method is not available.
The payment method specified in the payment_method argument is disabled or does not exist.
Unable to place order: Some of the products are out of stock.
Some of the products in a cart are out of stock.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.