Cancelling Fulfillments does not open fulfillment status - API and Admin UI

Solved

Cancelling Fulfillments does not open fulfillment status - API and Admin UI

Tryhard
Excursionist
25 2 17

There is no way to actually cancel fulfilments in a way that opens the fulfilment status so that it can fulfilled again through the API. I have tried cancelling both through the Admin UI and trough GraphQL. While both of those come up with no errors, the actual fulfilment status stays closed and the orders can't be fulfilled through API anymore. Below is the error that we get when trying to fulfill orders again after cancellation. This issue has been unsolved for years and it's time to resurrect and fix it. 

 

{
  fulfillment: null,
  userErrors: [
    {
      field: [Array],
      message: 'Fulfillment order XXXXXX has an unfulfillable status= closed.'
    }
  ]
}

Edit:

To add - the API actually returns that the order is fulfillable, yet it can not be fulfilled again as can be seen above. Below is what the API returns on the fulfill status of the order.

"fulfillable": true,
"displayFulfillmentStatus": "UNFULFILLED",


My best guess is that the reason for this behaviour is that the endpoint requires fulfillmentOrderId and if we give an old one, obviously it is already closed. But there is no way to create a new one with GraphQL (REST works) as the endpoint requires this ID. How absolutely confusing.

Accepted Solution (1)

Tryhard
Excursionist
25 2 17

This is an accepted solution.

OK, I have cracked this and the answer is quite obvious. 

What you need to do is to get the very last (none of the earlier) fulfillmentOrder ID from the orders

fulfillmentOrders(first: 1,reverse:true)


and use that ID when you send request to fullfillmentCreateV2

{
  "fulfillment": {
    "lineItemsByFulfillmentOrder":{
      "fulfillmentOrderId":"gid://shopify/FulfillmentOrder/XXXXXXX"
    }
  }
}

 
The answer is obvious now, but it's not explained in the docs and all the answers given by previous people who had this issue are wrong (they take the first without reversing).

Thanks and I hope this will help others who had the issue without a proper answer for years, lol.

View solution in original post

Replies 2 (2)

Tryhard
Excursionist
25 2 17

This is an accepted solution.

OK, I have cracked this and the answer is quite obvious. 

What you need to do is to get the very last (none of the earlier) fulfillmentOrder ID from the orders

fulfillmentOrders(first: 1,reverse:true)


and use that ID when you send request to fullfillmentCreateV2

{
  "fulfillment": {
    "lineItemsByFulfillmentOrder":{
      "fulfillmentOrderId":"gid://shopify/FulfillmentOrder/XXXXXXX"
    }
  }
}

 
The answer is obvious now, but it's not explained in the docs and all the answers given by previous people who had this issue are wrong (they take the first without reversing).

Thanks and I hope this will help others who had the issue without a proper answer for years, lol.

mfcss
Explorer
65 6 28

Saved my day, thank you