How can I display leading zeros in count variable for invoices?

Hello, I am using Order Print and the count variable to display a number on my invoices. I need the number to start with: GS000100. For some reason the 3 zeros in the front do not display and I see instead: GS100. Is there a way to fix this? Thank you so much!

Code:

- Gutschrift-Nr. 
                              GS {% assign count = 000098 %}
                              {% for transaction in refund_transactions %}
                                {% assign count = count | plus: 1 %}
                                {{ count | plus: 1 }}
                              {% endfor %}

What it displays:

Screen Shot 2021-02-02 at 12.37.57 PM.png

Zeroes in front of the number are stripped, so you need to do some string manipulations like this:

{% assign number = 98 %}
  {{ number | prepend: "000000" | slice: -6, 6 }}

The code converts your number to string to prepend “000000” string and then leaves only the last 6 characters.

1 Like

thank you @tim_1 !