8r3nd4n
8r3nd4n

Reputation: 119

Getting a value from one of four conditional logic fields (Gravity Forms)

I need to do some calculations based off two different field options using something like conditional calculations.

The scenario: We book birthday parties.

In the first field (product), you can select the amount of performers (1 - 4) In the second field (product option), you can choose the duration of the party (60 mins, 75 mins, 90 mins) Each party price changes based on the number of performers and duration. Currently I have conditional logic that says, if I select one performer, then show the second field with prices for that. If they choose two performers, another product option field shows (using conditional logic) with the prices for those durations, and so on (showing a different duration field for each of the performer options, four in total). This works exactly as it should and the calculations show the total properly.

HOWEVER, I need to hook the performers and duration fields into Salesforce, which only lets you map a single field to a lead. So it comes undone as I need salesforce to read a single duration from one of the four conditional logic 'duration' option fields. What I was thinking is that there could be a new field that maps to the four duration fields and just echos whichever one was selected but I'm not sure if that is possible. Something like final duration value = whichever duration value from the four duration fields were selected.

The other option would be to have a single product field and single duration field, with the total field calculated based on the options chosen in those two fields.

if(performers == 1 && duration == 60 mins)
total = 300;
if(performers == 1 && duration == 75 mins)
total = 450;
if(performers == 2 && duration == 60 mins)
total = 600;

etc...

but I don't know if this kind of calculation is possible. What options do I have to try and achieve what I am after?

Cheers

Upvotes: 0

Views: 1475

Answers (1)

Dave from Gravity Wiz
Dave from Gravity Wiz

Reputation: 2869

There isn't a very elegant way to do this in Gravity Forms currently; however, I have a snippet you can use that will allow you to map those conditional fields to a single field on submission. This will capture the value of whichever field is conditionally "enabled" when the form is submitted.

https://gist.github.com/spivurno/7029518

This would go in your theme's functions.php file. Instructions inline.

Upvotes: 0

Related Questions