Mark an order as fulfilled in Shopify

Based on data from another API, I’d like to update the fulfilment status of specific orders in Shopify (and more specifically change it from Unfulfilled to Fulfilled).
The Send to Shopify step doesn’t account for this situation.

Can someone confirm that the correct way to do this then is to use the Send to an API and create a Private App in Shopify, similar to what is described here Mark as paid orders from the excel sheet &/or here Add new products to shopify from CSV - #5 by Massimo_Coppola?

Hi @Sophie_Gallet,

That’s correct. To update the fulfillment statuses of your Shopify orders, use our “Send to an API” step. Here’s a video walkthrough on how to do that.

You can generate your API credentials by creating a new private app in your Shopify store. Once generated, copy your API key and password as your respective username and password in the authentication settings.

Here’s the base URL to make your request to:
POST /admin/api/2021-01/orders/{Order: Id}/fulfillments.json

This is the request I had in my body:

{
  "fulfillment": {
   "location_id": 40640774281,
    "tracking_urls": ["{Tracking URL}"],
    "line_items": [
      {
        "id": {Line Items: Id}
      }
     ],
    "notify_customer": false
  }
}

Let me know if you have additional questions or need help configuring this step.

Thanks!
Daniel

2 Likes

I really appreciate the fast and detailed answer, thank you Daniel!

1 Like

I am having the following error whenever I execute the Api call. Any ideas?

{
  "errors": {
    "base": [
      "Line items are already fulfilled"
    ]
  }
}

Hi @collinson,

This means that the line items in your order are already fulfilled and no further updates can be made. When making a request to the API, we’ll want to ensure we’re updating line items that have not been fulfilled.

To do this, try using a “Filter rows” step after importing your orders with line items. Set the filter to Keep rows where Line Items: Fulfillment Status is not equal to fulfilled.

Hi @daniel,

It looks like POST /admin/api/2021-01/orders/{Order: Id}/fulfillments.json has now been fully deprecated by Shopify it is not working.

I have been trying to get /admin/api/2022-07/fulfillments.json to work for me with no luck. Part of the issue is that I do not have a fulfillment id - because the order hasn’t been fulfilled yet. Have you found a solution to this?

I tried the following, but I need the fulfillment order id, not the order id, it seems. Is there a way to use GET to grab a fulfillment id for the order? Would Shopify create that upon request?

I’m in a pinch the site I am working on is launching on Tuesday and I noticed the issue as I was running through my Flows to confirm they were all working properly and connected to the store instead of my test data.

Thank you for your help in the past! I appreciate it.

{
	"fulfillment": {
        "notify_customer": true,
		"location_id": 18014371875,
		"tracking_number": {Fulfillments: Tracking Number},
		"tracking_url": "{Tracking URL}",
		"tracking_company": "{Carrier}",
        "line_items_by_fulfillment_order" : [
              {
               "order_id": {Order: Id},
               "fulfillment_order_line_items": [{Line Items Fulfillment Array}]
              }
            ]
	}
}

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}
	}
}