How to fulfill shopify order via shopify API

shopify fulfillment order

How to fulfill Shopify order via Shopify API

If you recently migrated to the Shopify API version 2022-07 or planning to migrate to 2022-07 or higher from Shopify API version lower than 2022-04 you will notice that Shopify made breaking changes to the fulfillment order API.
If you are using your own fulfillment service, you can fulfill orders via Shopify API following the steps below.
Step 1:
Get List of fulfillment orders using the order Id:
API URL: https://your-store-name.myshopify.com/admin/api/2022-10/orders/4599844958385/fulfillment_orders.json
4599844958385 = $shopify order id
Step 2:
If fulfillment order exists, loop through each fulfillment order and if status of the “request_status” is “unsubmitted”, you will submit fulfillment request:
https:// your-store-name,myshopify.com/admin/api/2022-10/fulfillment_orders/5787678983/fulfillment_request.json
5787678983 = $fulfillment order id
Post data: array('fulfillment_request'=>array('message'=>'In Transit',
'fulfillment_order_line_items'=>array()) );

Step 3:
If the request submission returns success, you need to accept the fulfillment request.
Request URL: https:// your-store-name,myshopify.com/admin/api/2022-07/fulfillment_orders/$fulfillment_order_id/fulfillment_request/accept.json
data: '{"fulfillment_request":{"message":"$custom_message."}}'

Step 4:
Final step, create fulfillment(s) for the fulfillment order.
Request URL: https:// your-store-name.myshopify.com/admin/api/2022-07/fulfillments.json
Data:
{"fulfillment":{"message":"Package Shipped","notify_customer":"","tracking_info"
:{"url":":\/\/mytrackingurl.com\/trackid","company":" Tracking company name","nu
mber":""},"line_items_by_fulfillment_order":[{"fulfillment_order_id":null,"fulfi
llment_order_line_items":[]}]}}

Note: Data with $ sign is a variable and needs to be replaced with actual value.

Share: