How to get the value of order_count of customer at checkout

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.

Hi,

You can use the orders_count property on the customer object.

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

Try this one in your script

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