Discussing APIs and development related to customers, discounts, and order management.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi, i want to make a order using json api, but if i want to add products it auto makes a new product. So how do i still make a order using json api but with existing products in my shopify store so i dont have to mannually put all the information.
Hi @DionCosina 👋
Using Admin GraphQL API, we can use the `draftOrderCreate` mutation and pass `Product
mutation draftOrderCreate($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
id
}
}
}
{ // input variables
"input": {
"lineItems": [{
"variantId": "gid://shopify/ProductVariant/12345",
"quantity": 1
}]
}
}
Then the resulting `DraftOrder.id` can be used with the `draftOrderComplete` mutation to create the order:
mutation {
draftOrderComplete(id: "gid://shopify/DraftOrder/67890") {
draftOrder {
order{
id
}
}
}
}
Similarly in Admin REST API, we can create a new `DraftOrder` then complete the `DraftOrder` as well.
Hope that helps!
Umiko | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Umiko,
thanks for your explanation. I'm still not absolutely sure how to handle this. I'm in the same position as @DionCosina right now. I'm looking for a way to create order through the Shopify API without creating new products.
Is there any way to do this using simple JSON requests?
Kind regards,
Niklas
I am also trying to do something similar. I am also looking for a flow of how an order is created and what needs to happen to make it all the way through to payment using the shopify payment system.