• Resolved lgouaux

    (@lgouaux)


    Hi
    first thank you for your work

    I would like to use precision to calculate surface and need to get the total with a result precision without decimal and always up to

    example : one item will be *0.6 so if there are 2 items I will get 1.2 and if I set precision at 0 and your plugin gives me 1 but I need 2
    How can I do it ?

    thanks
    Laurent

Viewing 1 replies (of 1 total)
  • Plugin Author pbosakov

    (@pbosakov)

    Hi Laurent,

    The “precision” option will always round to the nearest integer.

    If you want to round up instead, you have two options.

    Option 1: you can remove the “precision” option and instead use a JavaScript event handler that fires after the calculation and does the rounding. This is an example:

    jQuery(function($) {
        $('form').on('wpcf7calculate', function() {
            var $field = jQuery('.wpcf7-calculation');
            $field.val(Math.ceil(parseFloat($field.val())));
        });
    });

    Option 2: the Pro version of the calculator plugin supports the “roundup” and “rounddown” options in addition to the “precision” option, so it will let you easily control the direction in which results are rounded. If you have any pre-sales or support questions related to the Pro version, you can contact me on my website.

    Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Precision calculator’ is closed to new replies.