• Resolved manuka

    (@manuka)


    Dear Petko,
    I would like to use your plugin for a simple price calculation. Its working perfectly fine. There is just a minor question: can I somehow force the plugin to always show two digits after komma, like 10.00 Euro?
    precision:2 does not force it two show 2 digits..
    Nice plugin!
    Regards, manu

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author pbosakov

    (@pbosakov)

    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));
        });
      });
    });
    Thread Starter manuka

    (@manuka)

    Beautiful!!! Thank you

    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

    Plugin Author pbosakov

    (@pbosakov)

    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 4 years, 11 months ago by webenergysas.
    Plugin Author pbosakov

    (@pbosakov)

    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 ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘two digits after komma’ is closed to new replies.