All things Shopify and commerce
I used to have this and it stopped working some time ago.
This is the code snippet I used and it displayed eg, [Order Count: 15] on the invoice
{% if customer %}
<li class="order-details-count">
<span class="order-details-title">Order Count:</span>
<span class="order-details-text">{{ customer.orders_count | default: 1 }}</span>
</li>
{% endif %}
For some time now it hasn't worked and I want it to work again. I have seen another discussion that this variable should work and it's dated March 2024
{{ order.customer.orders_count }}
But it doesn't work.
So what's the solution? The data exists because I can look at a customer in shopify and it shows me how many orders they have made. I just want this number to show on the invoice. What do I do?
hey @martybeany,
Check if {{ customer }} or {{ order.customer }} is available by outputting it directly in the invoice template
<pre>{{ customer | json }}</pre>
<pre>{{ order.customer | json }}</pre>
This will print out the customer object and let you see whether the orders_count field is included in the output
I added this to the invoice template
<pre>{{ customer | json }}</pre>
<pre>{{ order.customer | json }}</pre>
It generated 2 identical outputs: (personal info replaced with xxx)
{"id":3186859769988,"created_at":"2020-04-13T09:06:11.000+01:00","name":"xxxxx","email":"xxxxxx@icloud.com","phone":"+xxxxx6163","first_name":"xxx","last_name":"xxx","orders_count":1,"tax_exempt":false,"note":null,"tags":["repeat"],"default_address":{"id":6415828910233,"customer_id":3186859769988,"first_name":"xxx","last_name":"xxx","company":"","address1":"xxx road ","address2":"","city":"Trowbridge","province":"England","country":"United Kingdom","zip":"xxx","phone":"","name":"xxx","province_code":"ENG","country_code":"GB","country_name":"United Kingdom","default":true},"state":"enabled","total_spent":0}
The key info here being: "orders_count":1," and "total_spent":0
This specific customer has placed 60 orders so I don't think this is working
The {{ customer.orders_count }} field in Shopify represents the total number of fulfilled orders for a customer and does not include the current order unless it has been fulfilled. This is likely why you're seeing an incorrect count.
They have previously placed 59 orders but it says "orders_count":1,"
I just don't get it, is shopify broken or this function not available?
try to contact to shopify tech support team
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024