I have an App in the Shopify App Store that does functions related to 3rd party fulfillment for stores. I have a bone to pick with whoever decided the way fulfillment requests and cancellation requests should work, and I’m wondering how other people solve this problem.
The current flow is that I provide a callback url ending in ‘/fulfillment_order_notification’ when registering my fulfillment service in a store when someone downloads my app. After that, at various points in the order fulfillment process, the user can press the ‘Request Fulfillment’ or ‘Request Cancellation’ buttons built-in to Shopify Admin to take actions on the order.
When a store owner does either of those things, the ‘/fulfillment_order_notification’ endpoint is hit. This is where my issues begin, because the only thing Shopify sends here is a ‘kind’ value that’s either ‘FULFILLMENT_REQUEST’ or ‘CANCELLATION_REQUEST’. They don’t send any information as to which order the user just clicked ‘Request Fulfillment’ or ‘Request Cancellation’ on. This is a huge problem, because whenever someone sends a fulfillment or cancellation request, you have no idea which order they just acted on, so your only solution is to pull all orders of that status from the store. This entire process is described in the documentation here.
For fulfillment requests (even though its definitely a strange order of operations) this is fine for me, because we just accept fulfillments on all orders immediately. Fulfillment Request is hit → Pull ALL orders of status ‘FULFILLMENT_REQUESTED’ (because Shopify doesn’t tell you which order just got requested fulfillment on) → Accept fulfillment on all those orders. It doesn’t matter if someone clicks ‘Request Fulfillment’ and my app searches the store and finds more orders than what the user clicked on, because they’re all accepted anyway.
My specific issue is with the cancellation requesting. I am trying to send targeted notifications to team members based on these cancellation requests and I’m running into problems because, again, Shopify does not tell you which order the store owner just pressed ‘Request Cancellation’ on.
The specific scenario I have issue with is: Cancellation Request is hit → Pull ALL orders of status ‘CANCELLATION_REQUESTED’ (at this point in the scenario there’s just the 1) → Send internal notification about the request. Now, cancellation requests do not get accepted instantly the way fulfillment requests do, because we have to actually find the order and make sure it hasn’t shipped, etc. It can take time. So let’s continue the scenario: Internal notification is sent about the first cancellation request → Some time passes while we process → The store owner hits ‘Request Cancellation’ on a SECOND order (or more) BEFORE the previous cancellation request(s) have been accepted or denied → Pull ALL orders of status ‘CANCELLATION_REQUESTED’ again (now there’s more than one!) →
Now what. The original cancellation request is going to be pulled again because we haven’t accepted or denied it yet. With no way to tell which specific order the user pressed ‘Request Cancellation’ on, we have no way to tell which one we already sent an internal notification about. At this point, if we pull all orders for status ‘CANCELLATION_REQUESTED’ again and make notifications for them, we will be making duplicate notifications.
I’m wondering if anyone else has run into a similar problem and how they ended up solving it. Is the only solution really to store these cancellation requests internally just to track which ones Shopify has already sent?
Thanks