Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am trying to figure out how I can set a variable in my theme.liquid file to 3 decimals, it currently reverts to 2 decimals. So for example I may have a result calculation that should be 1.875 but it rounds to 1.87
I have tried to divide by a 3 decimal number, e.g. 100.000, or 1.000, or 2.000 etc
I have tried to set round to 3
I have tried to set abs
Nothing is working so far, it always reverts to 2 decimals.
Any suggestions?
Solved! Go to the solution
This is an accepted solution.
OK, I am not sure why but I was able to fix it by switching the order of my divide_by in the calculation.
Example
{{ settings.font_number_size | times: settings.font_default_scale | divided_by: settings.font_body_size | divided_by: 100.000 | round: 3 }}
To
{{ settings.font_number_size | times: settings.font_default_scale | divided_by: 100.000 | divided_by: settings.font_body_size | round: 3 }}
Well, it resolves my specific issue
I looked at this again and to be easier just adding a times or divide_by as 1.000 fixes it too.
For example
{{ settings.font_number_size | times: settings.font_default_scale| times: 1.000 | divided_by: settings.font_body_size | divided_by: 100 | round: 3 }}
This is an accepted solution.
OK, I am not sure why but I was able to fix it by switching the order of my divide_by in the calculation.
Example
{{ settings.font_number_size | times: settings.font_default_scale | divided_by: settings.font_body_size | divided_by: 100.000 | round: 3 }}
To
{{ settings.font_number_size | times: settings.font_default_scale | divided_by: 100.000 | divided_by: settings.font_body_size | round: 3 }}
Well, it resolves my specific issue
I looked at this again and to be easier just adding a times or divide_by as 1.000 fixes it too.
For example
{{ settings.font_number_size | times: settings.font_default_scale| times: 1.000 | divided_by: settings.font_body_size | divided_by: 100 | round: 3 }}
Where do you make this change? I am trying to get my cart to display .000 or .0000 (3 or 4) decimal places.
Where / what file are you making this modification to?
Where is this code to be inputted?
So, I was able to output this anywhere we were outputting price. The problem, is that regardless of us displaying the extra decimals, the Shopify cart WILL ALWAY round back with only the 2 decimal places. This caused more problems for accounting, so we had to move away from showing this value. Pretty frustrating when were were working on discounting with percents. We should the customer what percent discount they were getting, but in the end, Shopify always rounded up and the customer never got the full discount.
Hi @afcompany , I could not find this code in my theme.liquid, where did you make the changes?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025