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 %}
Order Count:{{ customer.orders_count | default: 1 }}
{% 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?
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.
@tiagos_souza it’s not that it should be deprecated, it’s just that the packing slip/invoice exposes very limited variables, primarily shop and order. Customer variables are exposed in templates like the order confirmation, so
{{ customer.orders_count }}
is definitely possible there. Checked it just now and it’s there. Just letting you know.