Replacement for: /admin/api/2021-01/orders/{Order: Id}/fulfillments.json
This code fulfills each line item that shipped and does not automatically fulfill the entire order. If you want to fulfill the entire order, you can use the JSON below, simply remove the line with the array in it.
Step One:
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Step Two: Use “Expand JSON” to the return for the following details
In the return, look for the column with the array in it and parse out the array. There are several columns of data needed from this array. Some of them are also outside of the array, but some are not. The array is called “api.fulfillment_orders line_items”. The columns you need, depending on your requirements, are:
api.fulfillment_orders id = fulfillment_orders_id
api.fulfillment_orders assigned_location_id = location_id
api.fulfillment_orders order_id = order_id
api.fulfillment_orders line_items variant_id = variant_id
api.fulfillment_orders line_items id = line item identifier needed for your ship quantity array
Admittedly, there may have been something with the way I pulled in this data that caused the array to occur. So you may not have to parse out the data, but in case you do, those are the details. After that, put together an array with your shipping info (only if you need it).
{"id": {api.fulfillment_orders line_items id}, "quantity": {Quantity Shipped}}
Step Three: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.fulfillment_orders id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.fulfillment_orders assigned_location_id}
}
}