How to automatically fulfill new fulfillment orders assigned to my fulfillment service

Solved
felipebrahm
Tourist
4 1 0

Hi,

 

I'm developing a custom app. I created a new Fulfillment Service with a callback URL. I want to completely automate the whole workflow without the merchant having to manually fulfill the line items that are part of the fulfillment service (but without enabling the Shopify automatic fulfillment for all orders).

The fulfillment service callback is only called after the line items have been fulfilled, so I can't use that. So I subscribed to the orders/paid webhook topic. Now, I'm notified whenever a new order is placed (and paid) and I can go through the line items to see if there's any line items that are to be fulfilled by my fulfillment service. What I'm having trouble with though is the next step where I need to automatically submit a fulfillment order request because I don't have the assigned fulfillment order id. So my specific question is: Is there a way to query (either via the REST or GraphQL APIs) the unsubmitted assigned fulfillment orders given an order id?

The only way I've found to do this would be to query for all assigned fulfillment orders and look for the one that matches the order id. But there seems to be no way of filtering nor sorting assigned fulfillment orders by date, so this could take a while and I might have to make several API calls to paginate and go through all the results.

Any help would be appreciated. Thanks.

0 Likes
felipebrahm
Tourist
4 1 0

This is an accepted solution.

Never mind. I figured it out. It was pretty straight forward but I somehow got confused between the concepts of "AssignedFulfillmentOder" and "FulfillmentOrder". To solve my problem I just needed to call /admin/api/2020-07/orders/{order_id}/fulfillment_orders.json

0 Likes