Display 000100 Count variable

Solved
Elisaw
Excursionist
40 1 4

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:

<li class="order_details">
                            <span class="order-details-title editable" data-key="number"> Gutschrift-Nr. </span>
                            GS {% assign count = 000098 %}
                            {% for transaction in refund_transactions %}
                              {% assign count = count | plus: 1 %}
                              {{ count | plus: 1 }}
                            {% endfor %}
</li>

 

What it displays:

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

0 Likes
tim
Shopify Expert
2862 118 938

This is an accepted solution.

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.

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
Elisaw
Excursionist
40 1 4

thank you @tim !

0 Likes