Hello,
i have a small problem with currencies formatting.
In Switzerland we are used to have 2 decimals after our currency value such as :
CHF 123.40 or CHF 10.25
But when we there is no decimals needed we replace it with a dash such as
CHF 100.– instead of CHF 100.00
I am looking to find the hook that handles the currency formating but just found "frm_currency" with wich i could change the currency symbol and position, or "frm_setup_new_fields_vars" with which i could change the amount value but not the formatted value, it seems to happend later… Or does it happend at the JS level ?
Thanks for your help
Hooks operate at the server level either before the form is rendered in the browser or after the form is submitted. If you want this to happen in the browser, you need to use jQuery/JavaScript. See this: https://formidable-masterminds.com/formatting-fields-as-currency/
Thanks Victor, so that happens at the JS level !
I just tried with JS unactivated and the formatting is still done in the product line. I will dig deeper into that problem.
"I just tried with JS unactivated" What does this mean?
I disabled JS to see how the numbers where formatted before any JS formatting. And my products are still listed as "product X : CHF 100.00". That means that FF has already formatted the price internally, as it is stored as 100 without any decimals.
Of course that's what would happen. You are running hooks that execute on the server. If you want the action to take place in the browser, deactivate your PHP snippets and use the JavaScript library I referenced.
I think it’s more efficient to change how the server handles formatting instead of letting it do its business and then change again the format on the client side. It seems redundant to me 🙂
it is redundant which is exactly why I recommend not using the hooks for this and using JS. That is the most efficient way.
I get your point. Thanks !
Please login or Register to submit your answer