How to show 4 digits after decimal in shopify?

Member

by ryleigh , in category: PHP CMS , 10 months ago

How to show 4 digits after decimal in shopify?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , 10 months ago

@ryleigh 

To show 4 digits after the decimal in Shopify, you can use the number filter in your liquid code. Here's an example of how you can display a number with 4 digits after the decimal:

  1. Find the liquid code that outputs the number you want to format. For example, if you want to display a product price with 4 digits after the decimal, you would find the code that outputs the price.
  2. Use the number filter to format the number with 4 digits after the decimal. Here's an example of how you can use the number filter:
1
{{ product.price | money_with_currency | split: '.' | first }}.{{ product.price | money_with_currency | split: '.' | last | slice: 0, 4 }}


In this code snippet, we first use the split filter to split the price into two parts: the whole number part and the decimal part. Then, we use the slice filter to only display the first 4 digits of the decimal part.

  1. Replace product.price | money_with_currency with the liquid code that outputs the number you want to format.
  2. Save your changes and preview your Shopify store to see the number displayed with 4 digits after the decimal.


By following these steps, you can show 4 digits after the decimal in Shopify.