Liquid, JavaScript, themes, sales channels
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?
User | RANK |
---|---|
38 | |
28 | |
13 | |
13 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023