How can I add four decimals to invoice numbers?

Topic summary

Goal: display numbers with four decimal places (including trailing zeros) in Shopify (Liquid), e.g., 1.2 → 1.2000 and 1.52 → 1.5246.

Solutions proposed:

  • String-slicing approach: multiply by 10,000, split on the decimal separator, and reconstruct using slices. Note: originally output 5 decimals but is easily adjusted; would need enhancement to handle commas as decimal separators.
  • Padding approach: round to 4 decimals, split into integer and fractional parts, then append “0000” to the fraction and truncate to length 4. This yields 1.76 → 1.7600 and preserves true four-decimal values like 1.7666. (Uses Liquid filters: round, split, append, truncate.)

Outcome: original poster confirmed success using split and size-based logic.

Open items: multiple users asked where to implement this (globally vs. per product, and how to override Shopify’s default 2-decimal display). No implementation location guidance was provided yet, so this remains unresolved.

Notes: This is a Liquid templating task; no images or attachments are central.

Summarized with AI on January 10. AI used: gpt-5.

Hi, I would use this method to achieve adding the trailing 0s. This will append a 0 up to 4 decimal places regardless of the rounding length.

For example you could have a price of 1.76 and it would display as 1.7600, or you could have a number of 1.7666 which would display as true 1.7666. You can adjust the round and truncate length if you want more or less 0s to trail. Hope this helps.

{% assign price = 1.765 %}
{% assign price_split = price | round: 4 | split: "." %}
{% assign int = price_split[0] %}
{% assign frac = price_split[1] | append: "0000" | truncate: 4, "" %}

Formatted: {{ int }}.{{ frac }}
3 Likes