Conditional Calculations [RESOLVED]

Hoping someone might be able to help.

Need to apply discounts to a field based on values chosen across 5 fields and trying to do so in the most efficient way possible.

Would love to write a calc that can access multiple field values on the form and do the applicable calculation.

For example:
Trying to set the number field, Product Cost based on the following:

If field A=10 and field B=Yes and field C=Green and field D=45 and field E=Square, then Product cost = (250101.08)+(45*.33)

However, I’d add several permutations of that calc based on varying values of fields A,B,C,D,E

Is there a fairly simple way to do this within the calculation area of the number field. If so, can you share the base syntax?

Much thanks!

There’s no simple way to do that in Gravity Forms. You would need to have an individual product, configured as a calculation. and show that conditionally based on all those possible choices in the form. One issue with that is that Gravity Forms does not support complex conditions such as “IF this field is SOMETHING AND IF another field is SOMETHING ELSE”. There is a 3rd party plugin to support that conditional logic, but even then, you would be configuring many many products.

One possible alternative if this plugin:

It’s a complex add-on, and I am not sure if that will actually accomplish what you need. However, they have some videos on their site, and a tutorial here:

Maybe that will give you some ideas you can work with?

Could you give more examples of the formulas you would be running and which values in those formulas would be field-based?

Thanks for the help thus far. Looking into the plugin to see if it will work for us.

Here are more details on the calculations:

The user will pick a class which has a specific price. There are 5 class choices.
The user has been previously assigned a discount code. There are 5 different discount codes.
The user may choose up to sign up to 3 people up in a single transaction and the discount code applies uniformly to all people.
Depending on their original discount code, they are offered a further discount if they choose to pay in full vs. make partial payment.
There is a registration fee for each person for which the discount code does not apply.
There is a materials fee for each person which varies by class and the discount code conditionally applies (applies for some discount codes, but not others).

So we need to add the following:
Class * Discount Code for up to 3 people
Materials Fee * Discount Code (conditionally)
Registration Fee for up to 3 people

Then, apply Supplemental Discount across entire transaction (conditionally).

So in summary, it’s a lot of “if” conditions. I was most recently looking into whether or not we could assign values to each of the conditions such that regardless of which class or discount code applied, you’d still just multiply them together without actually assessing them. Do you know if this is possible?

Most of the conditions are either Radio Buttons or Drop Downs, and have non-numeric choices, but in actuality each has a numeric value that can be assigned to it such that the calculation is constant regardless of their choices. Hoping this is possible as it seems it would be the simplest way of attacking all the permutations.

Disregard the last part of previous post regarding “values”. I thought I had seen it before but was looking in Advanced tab, but now I am easily seeing it in the General tab. I think I’m able to run with this now assuming calcs will use value.

If you need to use a value in a merge tag, for a calculation, you can add the :value modifier, like this:

{My Field Name:23:value}

If the field ID was 23, that value modifier will give you the value of the field to work with.

RESOLVED - Thanks everyone for the help. All calcs in with every permutation and working well. Did not need to use an add on plugin.

1 Like