Can we update an order’s status to be “canceled”? How would the request payload look for this? Sorry, still getting used to GraphQL.
Hi @matt_dataautomation
No problem at all! there is a mutation to cancel an order, it should look something like this one:
mutation {
order_cancel(
data: { order_id: "121147919", reason: "Testing Cancel Order" }
) {
request_id
complexity
order {
id
legacy_id
order_number
fulfillment_status
order_date
}
}
}
And in the response you should be able to see something like this:
"fulfillment_status": "canceled",
Let me know if that doesn’t help or I can assist you with anything else.
Thanks!
Tom
On a similar note, how do we retrieve the cancelation date and cancelation reason in a query? There does not seem to be a field for this in either order or orders.
Hi @Devin_Mabra
You can get that info by using the order_history
query, something like this:
query{
order_history(order_id: "121147919"){
request_id
complexity
data(first: 20){
edges{
node{
id
legacy_id
order_id
user_id
account_id
username
order_number
information
created_at
}
}
}
}
}
And it should show you something like:
{
"node": {
"id": "T3JkZXJIaXN0b3J5OjM2NTYwNTkzNw==",
"legacy_id": 365605937,
"order_id": "T3JkZXI6MTIxMTQ3OTE5",
"user_id": "VXNlcjo5MTIz",
"account_id": "QWNjb3VudDozODAx",
"username": "Tom Wingord",
"order_number": "TO-MO773",
"information": "<p>Order fulfillment status changed to: canceled</p><p><strong>Reason:</strong> Testing Cancel Order",
"created_at": "2020-04-04T07:51:33+00:00"
}
From when it was canceled.
Let me know if that doesn’t work for you.
Thanks again!
Tom
Hey, @tomasw thanks for the help! It does seem like this is a rather inefficient way to retrieve the cancelation date. Are there any plans to have a cancelation_date field in order?
Hi @Devin_Mabra !
You could use a webhook for those types of notifications. We have the Order Canceled Webhook for that purpose. It will trigger each time you cancel an order, so you don’t have to fetch the order status and verify if it’s canceled.
I did find that we don’t store something like order canceled date in our DB other than in the order history.
Let me know if this still doesn’t work for you
Thanks again!
Tom