customer.orders not returning all orders.

Mahmoud_Yousif
New Member
6 0 0

Hey all,

I've been trying to retrieve all the orders a customer has placed with my shop, but when I call customer.orders, it only returns 20 orders (the customer has place 43 orders). The shopify API documentation doesn't describe any limits on this call. Has anyone experienced this issue before? Anyone with any ideas on how to resolve?

Thanks!

0 Likes
Jurgen_Feuchter
Shopify Partner
222 1 26

Hey Mahmoud, 

All API calls have a limit of 25 to 50 lines by default usually. But you can set them up to a max of 250 lines per call. Just add the property "limit=250" and youll get a max of 250 lines.

Aditionally if you are going to get more then 250 you can use a "/count.json" endpoint to see how many orders, products or customers you are bringing with you query and do a loop accordingly to bring all the lines for that query.

I hope I explained myself here haha, if you have any questions, do ask :D Good luck!

Cheers!

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
Mahmoud_Yousif
New Member
6 0 0

Hey Jurgen,

Thanks for taking the time to reply! So how would I add this argument? Would I have to make an ajax call as opposed to using the liquid global object? Or is there some kind of configuration I can change in one of the json files?

0 Likes
Jurgen_Feuchter
Shopify Partner
222 1 26

Hey Mahmoud, 

So you are talking about liquid code? if so it would be something like: 

{% for order in customer.orders by 250(250 is max) %}
code
{% endfor %}

in liquid code you can add the by to increase the limit of orders for each pagination, If Im not mistaken the max is 250. Hope this helps. 

You can see more here: https://help.shopify.com/en/themes/liquid/tags/theme-tags#paginate Its a pagination on products, but should work the same for orders.

Cheers!

 

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
Mahmoud_Yousif
New Member
6 0 0

Thanks for all your help!

0 Likes
mecdev
New Member
1 0 0

This does not work for us. It still returns 20 orders after adding the limit.

0 Likes
Boots
Shopify Partner
21 0 28

This is pretty old, but I ran across it today and wanted to make sure it was answered...

 

As far as I know, the only way to show more than the default 20 orders on a page is to use the `paginate` tag.  You would do something like this:

 

{% paginate customer.orders by 250 %}
{% for order in customer.orders %}
        display order data here...
{% endfor %}
{% endpaginate %}

 

That works for me.  I've heard there's a dead limit at 250, but I haven't seen any official word on that, and I don't have enough orders under any one customer to test it.

 

Hope that helps!

0 Likes
FazilHaneef
New Member
3 0 0

@Boots I'm having the same issue. One of our customer have 38 orders and it only shows 20 in his account. I tried the code you provided in "customers/account.liquid", "customers/order.liquid", "index.liquid" it didn't work. Am I doing something wrong or is the code not working for me?

 

Thanks,

Fazil

0 Likes
Boots
Shopify Partner
21 0 28

Hmmm...  I'm using that code in the `customers/account.liquid` template and it works great.  Just to make sure, I just tested this exact code in my account page and it worked:

{% paginate customer.orders by 250 %}
<ul>
	{% for order in customer.orders %}
	<li>Order #{{ order.order_number }}</li>
	{% endfor %}
</ul>
{% endpaginate %}

 

Unfortunately, I don't know what might be going wrong for you. 🤷‍

0 Likes
FazilHaneef
New Member
3 0 0

@Boots Weird, I just tried the code from your response, it's now able to fetch the orders but not in the table as the other orders, but as a separate list. I mean I do understand it's bullets because of the unordered list, I'm trying to understand why it's not continuing in the table above

FazilHaneef_0-1615499721250.png

 

 

0 Likes