Conditional Pricing w/Dynamic Field Population?

I have setup an event registration form which is dynamically populated with event info via the shortcode for the form. Works great.

We offer earlybird pricing for some of our events, but the Conditional Pricing Perk does not have the capability to define the price using a variable.

I’m trying to calculate the price using Javascript in an HTML field on the form. I can use other dynamically populated fields and a date function to accomplish the task. How do I get and set values of the fields on the form? For example, the Form # is 88. The Product Field # is 48, and I see that the Product Label has the class of “gfield_label”. But this does not work:
document.getElementById(“field_88_48”).getElementsByClassName(“gfield_label”)[0].html=“My Field”; (.innerHTML does not work either)
Similarly, how would I grab the value from a Number Field whose ID is 44?

Or maybe I’m taking the wrong approach?

Thanks.

This is pretty simple, I just don’t know enuf PHP/GForm programming to install it.
Let me try to present it differently:

The goal is add early bird pricing to a product form.

Using dynamic population via shortcodes, I have the following fields:
field_88_44 which is a Number with param name: cost1
field_88_45 which is a Number with param name: cost2
field_88_42 which is a Date with param name: earlybird_date
field_88_34 which is a Product with 2 param names: prod_name & prod_cost

prod_cost will be populated with this script, but I need the prod_name to be populated from the shortcode, so the Product field needs to have dynamic population enabled.

So the task is to compare the earlybird_date to Current Time (now), then populate prod_cost with either cost1 or cost2.

//In psuedo code, get the values from the fields and set prod_cost using cost():
var earlybirdPrice = cost1.value()
var regularPrice = cost2.value()
prod_cost.value = = cost();

And the function:

var cost =() => {
    var finalDate = new Date(earlybird_date);
    var today = Date.now()
    return (today<=finalDate ? earlybirdPrice : regularPrice);
}

If someone could tell me how to do this in GForms, I’d be grateful.
Thanks.

Gravity Wiz also has a Conditional Logic Dates snippet, because GF does not natively support conditional logic on date fields. Make a hidden datepicker field which autopopulates with today’s date - just select the correct format merge tag in Advanced > Default Value. With the snippet, your date field should be available in Conditional Logic choices.
I don’t currently have either the Conditional Pricing or Conditional Logic Dates snippets installed to test, but I think the worst that would happen is that you’d have to use separate products or product options for the different prices instead of conditional pricing.
Hope this helps.

Thanks Susan:
Until now I have been Conditional Pricing addon, but in this case I am passing the prices via shortcode and the prices in the Conditional Pricing Addon can’t be pulled from other fields, they must be entered directly. Hence I need to write custom code to add that capability to our registration system (or manually change the cost shorcode at the end of early bird pricing).

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.