Re: How to Cancel order by API with GraphQL or API call

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
Community Manager
3107 340 871

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
Community Manager
3107 340 871

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
Community Manager
3107 340 871

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
12 1 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
1453 238 508

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