What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Cancelling "Closed" Fulfilment Orders is not possible

Solved

Cancelling "Closed" Fulfilment Orders is not possible

gabripaz
Shopify Partner
7 0 4

Hello,
As process to migrate the cancel endpoint on the Fulfillment API due to its deprecation on version 2022-10, it is necessary to adapt requests made from Cancel Fulfillment to Cancel Fulfillment Order. However, it is not possible to Cancel a "Closed" Fulfillment Order using the FulfillmentOrder resource.

The following response is received:

Error 422 - "Fulfillment order is not in cancelable request state and can't be cancelled.".

Furthermore, it is possible to cancel the fulfillment manually by going to the order and cancelling the desired fulfillment.


cancelFulfillmentInOrder.png

 

So, since "Cancel" it is not one of supported actions for Fulfillment Order and Cancel Fulfillment is deprecated in version 2022-10, what should we do cancel an fulfillment successfully?


Thank you!

Accepted Solution (1)
RobZone
Shopify Staff
77 11 22

This is an accepted solution.

Yes, only the "/orders/{order_id}/fulfillments/{fulfillment_id}/cancel.json" endpoint is deprecated.  Use "/fulfillments/{fulfillment_id}/cancel.json" instead. 👍

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 6 (6)

gabripaz
Shopify Partner
7 0 4

[Update]

In 2020-10 release notes it is mentioned that the cancel fulfilment would be deprecated.

gabripaz_0-1671806617599.jpeg

 

In Fulfilment page after checking the changes between 2022-04 and 2022-10, we can verify the the cancel request that the release notes might be referring is the one that goes through order id.
So, will the endpoint "/admin/api/2022-10/fulfillments/{fulfillment_id}/cancel.json" be deprecated?

gabripaz_1-1671806617601.jpeg

 

 

gabripaz_2-1671806617601.jpeg

 

Thomotron
Shopify Partner
7 0 3

I've run across this recently as well while trying to cancel fulfilments akin to what's available in the web UI. Glad to see I haven't gone crazy searching through the API!

 

For what it's worth, this seems to make it impossible to programmatically cancel a partially fulfiled order via the REST API. In my instance, I have an order with three fulfilment orders: one completed, and one more open and unfulfiled at either location. Until that completed fulfilment is cancelled, the order will complain with a 422: "Cannot cancel a paid and fulfilled order". The GraphQL API does not provide any relief either.

RobZone
Shopify Staff
77 11 22

This is an accepted solution.

Yes, only the "/orders/{order_id}/fulfillments/{fulfillment_id}/cancel.json" endpoint is deprecated.  Use "/fulfillments/{fulfillment_id}/cancel.json" instead. 👍

To learn more visit the Shopify Help Center or the Community Blog.

Thomotron
Shopify Partner
7 0 3

Ah, thanks for pointing that one out! I feel a bit dumb for not looking harder at the API docs.

Radixsecur1ty
Shopify Partner
21 4 7

I receive the same error via Graphql API
https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/fulfillmentOrderCancel

mutation fulfillmentOrderCancel($id: ID!) {
fulfillmentOrderCancel(id: $id) {
fulfillmentOrder {
id
status
requestStatus
}
replacementFulfillmentOrder {
id
status
requestStatus
}
userErrors {
field
message
}
}
}

{
"id": "gid://shopify/FulfillmentOrder/6539764859058"
}

Response:
{
"data": {
"fulfillmentOrderCancel": {
"fulfillmentOrder": null,
"replacementFulfillmentOrder": null,
"userErrors": [
{
"field": null,
"message": "Fulfillment order is not in cancelable request state and can't be canceled."
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1990,
"restoreRate": 100
}
}
}
}

what can be wrong here?

RobZone
Shopify Staff
77 11 22

Why are you trying to cancel a closed fulfillment order?  Since no further action can occur on a closed fulfillment order, the cancel request fails by design.  There is a state machine diagram in the documentation if that helps: https://shopify.dev/docs/apps/build/orders-fulfillment/fulfillment-service-apps#statuses

 

To learn more visit the Shopify Help Center or the Community Blog.