Solved

How to Cancel order by API with GraphQL or API call

noptech
Shopify Partner
6 0 0

Hello,

I'm trying to find a way to Cancel an order via API or GraphQL, can you give me an up-to-date solution that works?

Thanks

Accepted Solution (1)
Liam
Shopify Staff
2731 302 777

This is an accepted solution.

Hi again Noptech,

 

You should be able to use the /cancel.json endpoint on the Order API to achieve this. There's an example of what that call would look like in our developer docs here

 

Hope this helps,

Liam | Developer Advocate @ 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

View solution in original post

Replies 6 (6)

Liam
Shopify Staff
2731 302 777

Hi Noptech,

 

This would depend on the specific type of order you're looking to cancel. Would this be simply refunding an order that's been made, or cancelling a fulfilment order that's in a fulfilment process (or cancelling an order before it's completed checkout)? 

Liam | Developer Advocate @ 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

noptech
Shopify Partner
6 0 0

This is a cancellation of the order process (without refund).

I want to perform the "Cancel" function, as there is a dropdown button in the order itself.

And the order should remain crossed out.

Liam
Shopify Staff
2731 302 777

This is an accepted solution.

Hi again Noptech,

 

You should be able to use the /cancel.json endpoint on the Order API to achieve this. There's an example of what that call would look like in our developer docs here

 

Hope this helps,

Liam | Developer Advocate @ 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

_frank_
Shopify Partner
3 0 0

Is is possible to cancel an order via the graphql api? Not finding it in the docs...

TheodorFreundHT
Shopify Partner
7 0 0

Hey Liam,

Even though this is marked as accepted answer, it doesn't really answer the question of the topic. So maybe you can clarify: Is there a way to use the GraphQL api to cancel an order or do you have to go the long way then and use orderEdit and the like to manually do all that?


Thanks so much for your answer

Theo

ShopifyDevSup
Shopify Staff
1363 228 478

Hey @TheodorFreundHT , This is a great question. There is not currently a mutation to cancel an order through GraphQL. There is an orderClose mutation you can use, however that emulates the behaviour of archiving an order. 

The order cancel option in REST is currently the only option via API. It does have conditions on how it would work that are indicated on the developer documents, but if the conditions are met, that's going to be the easiest way. 

I've submitted feedback to our product teams that this functionality is requested in GraphQL. IF it's added, it will be noted in our API release notes. 

Hope that helps. 

- Kyle G. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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