Dear Manu,
You can try adding this post-processing Javascript to your website.
jQuery(function($) {
$('form').on('wpcf7calculate', function() {
$('.wpcf7-calculation').each(function() {
$(this).val(parseFloat($(this).val()).toFixed(2));
});
});
});
Dear Petko, thanks for this solution for two digits after comma, it works flawlessy.
How to adjust your jquery function so that displayed calculation result number is:
– two digits after comma
– decimals divider , (instead of .)
– thousands divider . (instead of ,)
– € currency symbol before number
Thanks in advance for your help!
Angelo
Hi Angelo, try this one:
jQuery(function($) {
$('form').on('wpcf7calculate', function() {
$('.wpcf7-calculation').each(function() {
var formatted = new Intl.NumberFormat('it-IT', { style: 'currency', currency: 'EUR' }).format($(this).val());
$(this).val(formatted);
});
});
});
Thanks Petko.
Tried, but it returns me an error:
Parse error: syntax error, unexpected ‘$’, expecting variable (T_VARIABLE) in /home/petsfitn/public_html/portamilapizza.it/wp-content/themes/neve/functions.php on line 19
Any hint on how to solve?
Thanks.
Here’s the page where I’m testing the module:
https://www.portamilapizza.it/demo2/
WordPress 5.3.2
PHP 7.1.33
-
This reply was modified 6 years, 1 month ago by
webenergysas.
It looks like you included the code in your functions.php file, but this is actually JavaScript code, not PHP. It should go in the front-end section of your website.
I have had good experience with this third-party plugin that helps you easily add JS snippets to your site: Simple Custom CSS and JS
Hope that helps!
It worked!
I used your suggested plugin and now your code works perfctly.
Thanks again for your precious help.
Angelo
PS: the snippet for two digits worked in functions.php too 🙂