Solved

How can I get all orders by /admin/orders.json filter by fulfillment_status

ian4
Shopify Partner
6 0 1

I want to get all the orders(fulfilled and unfulfilled) from the api url, but I only get the unfulfilled orders by /admin/orders.json?fulfillment_status=any.

And I also get the unfulfilled orders by /admin/orders.json?fulfillment_status=shipped.

WHY?

Accepted Solution (1)
Gregarican
Shopify Partner
1033 86 285

This is an accepted solution.

I stumbled upon something in terms of filtering a GraphQL orders query by fulfillment status. The query terms don't necessarily match up with the field values that are displayed when the data is returned back in the response.

So for example, if I were to query an orders that had a fulfillment status of unfulfilled, I'd need to do something like this:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:unshipped") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

And if I were to query for any orders with a fulfillment status of fulfilled, I'd need to do this:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:shipped") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

 And finally, for those partially fulfilled orders:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:partial") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

It wouldn't be the worst idea if someone at Shopify expanded on the GraphQL API documentation so that the exact query terms would be spelled out!

View solution in original post

Replies 16 (16)

Felix2
Shopify Partner
98 0 17

As far as I can see, the fulfillment_status "any" is the default (https://help.shopify.com/api/reference/order#index).

Doesn't it work without adding the filter?

I faced the "issue", that the default filter for "status" is not "any" but "open".

Hope this helps.

Looga.io

ian4
Shopify Partner
6 0 1

I mean the fulfillment_status, not the order status.

It doesn't work without the fulfillment_status filter, it only returns the unfulfilled orders but no fulfilled orders.

Gareth_Doherty1
Shopify Partner
49 0 24

After some testing, it appears that the "fullfilment_status" filter is designed to act as a secondary filter, you mainly use after the status filter. I currently have 3 open orders, 1 cancelled and 85 closed. Here are the results of my testing using this filter.

admin/orders.json?fulfillment_status=shipped (no results, because without a filter on the default orders API, it is trying to check the open orders to see if they have been shipped)

admin/orders.json?status=any&fulfillment_status=shipped (85 results, because I have told it to bring back all orders using status=any and out of all of them, 85 are one\shipped)

admin/orders.json?fulfillment_status=unshipped (3 results, because without a filter on the default orders API, it is checking the open orders for to see if they are unshipped, which they are).

admin/orders.json?status=any&fulfillment_status=unshipped (4 results, because I have asked for all orders using status=any which includes my 3 open orders and the 1 cancelled order which has not been fulfilled\shipped)

admin/orders.json?status=any&fulfillment_status=partial (no results because I don't do partial fulfilment orders)

admin/orders.json?fulfillment_status=any (returns 3, because the default API call returns only open orders)

admin/orders.json?status=any&fulfillment_status=any (returns 89, because it is now saying, give me all orders with any fulfilment status)

Hopefully, this is useful to you and anyone else. 

Like mentioned previously by someone else, it appears to achieve what you think you want to achieve if you stick with status=any to bring back every order (fulfilled an unfulfilled). At the moment apart from wanting to return partially fulfilled orders, I can see no reason to have to use the fulfillment_status filter.

If using order status (status=any) definitely isn't what you want to do, and you believe fulfilment status is what you want, then maybe explain the scenario and outcome you are trying to achieve. Maybe we can come up with a solution for you.

Regards

Gareth

Vexebot
Shopify Partner
3 0 0

Hey guys is there any way to get the total value of the fullfilled or unfullfilled orders?


@Gareth_Doherty1 wrote:

After some testing, it appears that the "fullfilment_status" filter is designed to act as a secondary filter, you mainly use after the status filter. I currently have 3 open orders, 1 cancelled and 85 closed. Here are the results of my testing using this filter.

admin/orders.json?fulfillment_status=shipped (no results, because without a filter on the default orders API, it is trying to check the open orders to see if they have been shipped)

admin/orders.json?status=any&fulfillment_status=shipped (85 results, because I have told it to bring back all orders using status=any and out of all of them, 85 are one\shipped)

admin/orders.json?fulfillment_status=unshipped (3 results, because without a filter on the default orders API, it is checking the open orders for to see if they are unshipped, which they are).

admin/orders.json?status=any&fulfillment_status=unshipped (4 results, because I have asked for all orders using status=any which includes my 3 open orders and the 1 cancelled order which has not been fulfilled\shipped)

admin/orders.json?status=any&fulfillment_status=partial (no results because I don't do partial fulfilment orders)

admin/orders.json?fulfillment_status=any (returns 3, because the default API call returns only open orders)

admin/orders.json?status=any&fulfillment_status=any (returns 89, because it is now saying, give me all orders with any fulfilment status)

Hopefully, this is useful to you and anyone else. 

Like mentioned previously by someone else, it appears to achieve what you think you want to achieve if you stick with status=any to bring back every order (fulfilled an unfulfilled). At the moment apart from wanting to return partially fulfilled orders, I can see no reason to have to use the fulfillment_status filter.

If using order status (status=any) definitely isn't what you want to do, and you believe fulfilment status is what you want, then maybe explain the scenario and outcome you are trying to achieve. Maybe we can come up with a solution for you.

Regards

Gareth


 

KarlOffenberger
Shopify Partner
1873 184 900

@Vexebot Using Admin REST API orders endpoint no - unless you fetch all and do the math yourself in your app. If you have access to ShopifyQL then yes (minimum Shopify Advanced plan required).

Hasankhn
New Member
7 0 0

Hi , i cannot get the order which is fulfilled using this status 😞

Hasankhn
New Member
7 0 0

Is there any limit for the orders on api, and i am getting same data for every query why is that 😞 , i tried all combinations of query params but i get the same response again and again, and i can't even find the order which i want but it's status is fulfilled

Please help!

Thanks

Gregarican
Shopify Partner
1033 86 285

I have found some quirks using the GraphQL API in this regard as well. Below is a screen shot, where I am trying to pull the 5 most recent orders that have been fulfilled. Perhaps I'm mistaken in my query syntax since perhaps this is interpreted as a loose search. Where the characters fulfilled  are contained in unfulfilled as well as partially_fulfilled?

 

Order Query.jpg

Gregarican
Shopify Partner
1033 86 285

This is an accepted solution.

I stumbled upon something in terms of filtering a GraphQL orders query by fulfillment status. The query terms don't necessarily match up with the field values that are displayed when the data is returned back in the response.

So for example, if I were to query an orders that had a fulfillment status of unfulfilled, I'd need to do something like this:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:unshipped") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

And if I were to query for any orders with a fulfillment status of fulfilled, I'd need to do this:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:shipped") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

 And finally, for those partially fulfilled orders:

 

{
  orders(first: 5, reverse:true, query: "fulfillment_status:partial") {
    edges {
      node {
        name
        id
        displayFulfillmentStatus
        displayFinancialStatus
      }
    }
  }
}

 

It wouldn't be the worst idea if someone at Shopify expanded on the GraphQL API documentation so that the exact query terms would be spelled out!

theptrk
Tourist
9 1 5

Wow, @Gregarican  how did you find this? I've spent weeks on this issue. This is nowhere in the documentation.

Vinh
Shopify Partner
13 0 4

If someone using the shopifyAPI python library for making paginated requests for orders and want both fulfilled, open and more, this is how to fetch the first page. You can then use the column fulfillment_status to differenciate fulfilled vs open.

shopify.Order.find(limit=250, created_at_min=created_at_min, status='any')

 

I build processes and products around Shopify and ReCharge API
kpublik
Visitor
2 1 0
I too thank you  @Gregarican.!!
 
It was really frustrating to get filtering working on fulfillment_status.  First, the API docs are not correct, as seen below in the "Order" reference.
 
Screen Shot 2021-04-16 at 02.14.01.png
 
 
 
And elsewhere in the documentation, the example from the GraphQL Learning Kit also uses the incorrect value.
 
Screen Shot 2021-04-16 at 02.36.58.png
 
 
 
The API documentation and examples need to be updated!
Leocxy88
Shopify Partner
4 0 3

I really really hate their GraphQL docs. It is a nightmare. 

 

If you want to filter unfulfilled order, you need the query and reverse:true

{
  orders(first: 10, reverse:true, query:"fulfillment_status:unshipped") {
    pageInfo {
      hasNextPage
    }
    edges {
      node {
        id
        processedAt
        displayFulfillmentStatus
        displayFinancialStatus
        totalPrice
      }
      cursor
    }
  }
}

 

shop_dev1
Shopify Partner
32 0 2

Hello @Gareth_Doherty1 

I am working on to delete product from admin automatically when particular order fulfilled, for that I am using order rest api and get all orders but when I want to get only fulfilled orders I can not get that.

Can you please check my code and help me in this ?

$getOrders = shopify_call($access_token, $shop, "/admin/api/2023-04/orders.json", array("fulfillment_status" => 'fulfilled'), 'GET');
garylake
Shopify Partner
2 0 0

This might be from 2018 but thank you, absolute life saver! This is the documentation! 😅

ian4
Shopify Partner
6 0 1

Thank you very much! Gareth.