Anchor to draftOrderCompletedraft
draftOrderComplete
mutation
Requires access scope. Also: The user must have access to mark as paid, or set payment terms.
Completes a draft order and creates an order.
Anchor to Arguments
Arguments
- Anchor to bypassCartValidationsbypass•
Cart Validations BooleanDefault:false Whether to bypass cart and checkout validations. This will ignore any validations added by apps during completion.
- •ID!required
The draft order to complete.
- Anchor to paymentGatewayIdpayment•
Gateway Id The gateway for the completed draft order.
- Anchor to sourceNamesource•
Name A channel definition handle used for sales channel attribution.
- Anchor to paymentPendingpayment•
Pending Whether the payment is pending. Create a draft with payment terms rather than marking the draft as pending.
Was this section helpful?
Anchor to DraftOrderCompletePayload returnsDraftOrderCompletePayload returns
- Anchor to draftOrderdraft•
Order The completed draft order.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Complete a draft order
- Complete a draft order with payment pending
- Completing a draft order with an invalid payment gateway returns a user error
- draftOrderComplete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation draftOrderComplete($id: ID!) {6 draftOrderComplete(id: $id) {7 draftOrder {8 id9 order {10 id11 }12 }13 }14 }`,15 {16 variables: {17 "id": "gid://shopify/DraftOrder/276395349"18 },19 },20);2122const data = await response.json();23
mutation draftOrderComplete($id: ID!) {
draftOrderComplete(id: $id) {
draftOrder {
id
order {
id
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } }",
"variables": {
"id": "gid://shopify/DraftOrder/276395349"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation draftOrderComplete($id: ID!) {
draftOrderComplete(id: $id) {
draftOrder {
id
order {
id
}
}
}
}`,
{
variables: {
"id": "gid://shopify/DraftOrder/276395349"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation draftOrderComplete($id: ID!) {
draftOrderComplete(id: $id) {
draftOrder {
id
order {
id
}
}
}
}`,
"variables": {
"id": "gid://shopify/DraftOrder/276395349"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation draftOrderComplete($id: ID!) {
draftOrderComplete(id: $id) {
draftOrder {
id
order {
id
}
}
}
}
QUERY
variables = {
"id": "gid://shopify/DraftOrder/276395349"
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "id": "gid://shopify/DraftOrder/276395349"3}
Response
JSON1{2 "draftOrderComplete": {3 "draftOrder": {4 "id": "gid://shopify/DraftOrder/276395349",5 "order": {6 "id": "gid://shopify/Order/1073459966"7 }8 }9 }10}