Re: How to get the value of order_count of customer at checkout

How to get the value of order_count of customer at checkout

Ali_Zeeshan
Shopify Partner
18 3 2

I am using the following code to count the orders  f a counter at additional scripts for checkout 

{% assign customer = customer %}
{% assign order_count = 0 %}
{% for order in customer.orders %}
{% assign order_count = order_count | plus:1 %}
{% endfor %}


But I am getting the value 0.


I have orders under that account. Can someone please let me know how to get the actual value. 

Replies 2 (2)

jazz-jay
Shopify Partner
96 14 17

Hi,

 

You can use the orders_count property on the customer object.

https://shopify.dev/api/liquid/objects/customer#customer-orders_count

banned

Mitrodol
Excursionist
31 1 22

Try this one in your script

 

orderCount: "{{ checkout.customer.orders_count }}"