• Resolved YENIER Nazim

    (@nazimyenier)


    How to adjust how many decimals should a calculation field round to, in Ninja Forms 3.0 ?

    This was very easy in 2.9
    I can’t find any simple issue in 3.0

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    Hey @nazimyenier,

    In THREE, with the calculations merge tag you can add a “:2” to round to 2 decimals.

    ie {calc:my_calc:2}

    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    We are also working on a more robust UI for calculations to allow for these kind of controls, but currently there is no roadmap.

    Thread Starter YENIER Nazim

    (@nazimyenier)

    Hi @kbjohnson90

    Sorry, it does not work.

    I am trying to display a final sum, round to an integer, in an HTML field.
    So I write this :
    {calc:montant_final:0}

    My calculation doesn’t display anything.
    I tried with {calc:montant_final:1}. Nothing is displayed either.

    So does only {calc:montant_final:2} work ?

    If yes, this is a huge regression for sites selling services, like ours.

    • This reply was modified 8 years, 2 months ago by YENIER Nazim.
    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    We added the rounding to 2 decimal places for the purpose of payments.

    If you are needing to deal with whole numbers, then you can set the number fields to increment by 1, thus forcing whole numbers. Similarly, you can increment by .01, etc.

    Thread Starter YENIER Nazim

    (@nazimyenier)

    @kbjohnson90

    I don’t really understand.

    I don’t have any number field to increment on my form.

    I have
    – a radio list from which the client choose a service, let’s say for 169 euros (Calc : 169).
    – a dropdown list from which the client choose a discount, let’s say – 15 % (Calc : 0.85)

    My calculation for the final price is :
    {field:my_service} * {field:discount}

    For our example, this gives : 169 * 0.85 = 143.65 €

    Now, I want to display 144 € on my form.
    This was very easy in 2.9 with the calculation field.

    How to do it in 3.0 ?

    I tried to use {calc:my_field:2} as shortcut in the text-message of the success message.
    But this does not work.
    Know the shortcut is shown in this form {calc:gesamtbedarf:2} in frontent, not the number 1234.56.
    Where can I use the syntax with roundig?

    —-edit: sorry: there was an error in my code. Know the syntax {calc:my_field:2} is OK in the success message—

    • This reply was modified 8 years, 2 months ago by montviso.
    • This reply was modified 8 years, 2 months ago by montviso. Reason: syntax error found

    Reading this post, I actually still don`t understand how to round up decimals.

    In calculation tab I have two fields multiplied
    {field:where_are_you_staying}*{field:how_many_passengers_1}

    In html tab
    TOTAL TO PAY: {CALC:TOTAL COST} €

    Depending on which of the options client choose, the final TOTAL TO PAY displays 58.0808 eur, or 109.05000830001 eur, etc

    How I can round up decimals?

    Thank you in advance!

    TOTAL TO PAY: {CALC:TOTAL COST:2} €
    is working by me.

    Thread Starter YENIER Nazim

    (@nazimyenier)

    Dear friends,

    I want to round my calculation to an INTEGER.

    Not to a two decimals.

    If you read my example below, I wrote :

    I have
    – a radio list from which the client choose a service, let’s say for 169 euros (Calc : 169).
    – a dropdown list from which the client choose a discount, let’s say – 15 % (Calc : 0.85)

    My calculation for the final price is :
    {field:my_service} * {field:discount}

    For our example, this gives : 169 * 0.85 = 143.65 €

    Now, I want to display 144 € on my form.
    (not 143.65, but 144)

    How to do this in 3.0 ?

    A answer to the question about round to an INTEGER would be also for us helpfull.
    I don’t understand the solution with “increment by 1”.
    How can give an example?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to round a calculation in 3.0 ?’ is closed to new replies.