• Resolved morphpr

    (@morphpr)


    Hi

    I’m trying to prepare a quote calculator for a new boiler that is determined by two things: boiler type (A, B and C) and the number of bathrooms and the form should calculate a quote based on this information. Broadly speaking the calculation is value of boiler type field + (number of bathrooms *100). This would be really simple but the only problem is that there is an exception to the rule – for boiler type B the price for a two-bathroom home is the same as the price for a one bathroom home and it only goes up by 100 for each additional bathroom after bathroom 2 in the case of boiler type B. So with boiler B it is the same price whether you have a one bathroom home or a two-bathroom home because the basic boiler B type has the capacity to handle two bathrooms and only needs to be upgraded in terms of capacity for bathrooms above this number. Is there a way of accounting for this condition? Many thanks. Jamie

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @morphpr

    You should use conditional operations in the equation:

    
    type field + IF(AND(type field == 'B', number of bathrooms == 2), 1, number of bathrooms) * 100
    

    Of course, using the real fields’ names.

    Best regards.

    Thread Starter morphpr

    (@morphpr)

    Thanks. Appreciate this. So, now fitting that into the overall equation so including now the other more straightforward options where it simply adds 100 to the base value for the option A or C, I’ve got the following:

    prec(fieldname15 + IF(AND(fieldname15, dropdown == ‘option B’, fieldname13 == 2), 1, fieldname13) * 100)

    where fieldname 15 is a dropdown with the A, B amd C options and fieldname 13 is the drop-down where people select their number of bathrooms.

    Does that appear about right?

    Thanks again for your help.

    Jamie

    Plugin Author codepeople

    (@codepeople)

    Hello @morphpr

    No, the equation is incorrect. Please, send me the link to the page with the form to check the fields values.

    Best regards.

    Thread Starter morphpr

    (@morphpr)

    Sure. https://capagas-com.stackstaging.com/?cff-form=6

    Here’s a screenshot to show the field values for the A, B, C boiler options. As you can see it’s not actually A, B and C but in effect, it’s the same thing.

    https://www.dropbox.com/s/zszf9a8fw9c9npf/form_screenshot.png?dl=0

    Does this helps?

    Jamie

    Plugin Author codepeople

    (@codepeople)

    Hello @morphpr

    The equation would be:

    
    PREC(fieldname15 + IF(AND(fieldname15 == 2400, fieldname13 == 2), 1, fieldname13) * 100, 2)
    

    Best regards.

    Thread Starter morphpr

    (@morphpr)

    Thanks so much, you coding heroes. I will switch out the 2400 for the 1700 as in fact it’s the first option that the IF rule needs to apply to, despite my misleading you by saying Option B but yes that’s perfect.

    Thanks again. Now where can I give you a 5 star review?

    ??

    Plugin Author codepeople

    (@codepeople)

    Thread Starter morphpr

    (@morphpr)

    Hi Guys

    Hate to be a pest but I found that the equation needs a tiny tweak. It’s almost perfect. I had to adjust it very slightly because I was finding that when they choose the option from fieldname 15 which should start with 1 bathroom at 1700, two bathrooms also at 1700 and three bathrooms at 1800, 4 at 1900 etc it was in fact returning the figure 1800 for 1 bathroom and two bathrooms and 1900 for 3 bathrooms. I adjusted my value for this option in fieldname 15 down to 1600 and likewise adjusted the value referenced in the calculation and whilst this fixed the figure for one and two bathroom properties to the correct 1700 figure, 3 bathrooms now returns 1900, 4 bathrooms 2000 etc

    The current equation PREC(fieldname15 + IF(AND(fieldname15 == 1600, fieldname13 == 2), 1, fieldname13) * 100, 2)

    Could you possibly advise?

    Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @morphpr

    In this case, the equation can be edited as follows:

    
    PREC(fieldname15 + IF(fieldname15 == 1600, IF(fieldname13==1, 1, fieldname13-1), fieldname13) * 100, 2)
    

    Best regards.

    Thread Starter morphpr

    (@morphpr)

    Perfect. Thanks so much.

    Jamie

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘making an exception to a condition’ is closed to new replies.