PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Calculation Fields and Price Change Based on Field Inputs

  1. relish
    Member

    Hi,
    I am trying to create a form that allows users to register for a conference. The user is able to select an admission rate (Regular or Student) and an attendance date (a specific day or the entire conference). A different price should be applied depending on what is selected. Also, if the regular rate is selected, I would like to have price breaks at different quantity ranges.

    Here's where I run into problems using the calculation field type for the price field. Any calculation I enter in here results in a JS error on the post the form is displayed on. The form is also hidden on that post page. The markup is all there, but the div containing the form has the attribute style="display:none;". If I remove the calculation, the JS error is gone and the form appears again.

    The JS error I am getting is:
    expr is undefined expr = expr.replace(matches[i][0], value); gravityforms.js?ver=1.6.4.4.2 (line 838)

    I have a dropdown field named Admission with two choices and the Label=>Values are:
    Regular=>100 and Student=>55.

    In the product field I have tried the following calculations just for testing and they all give the same JS error:
    - {Admission:7}
    - {Admission:7} * 1
    - something simple like 1 + 1

    I am using v1.6.4.4.2 on WP v3.3.2.

    Am I doing something wrong? Is there a specific syntax for the calculations? Is it possible to put if/switch logic in there? If not, any ideas on how I can accomplish the business logic described above?

    Any help would be greatly appreciated.

    Thank you for your time.

    Posted 11 years ago on Friday May 25, 2012 | Permalink
  2. Does the form in question show and work in the formbuilder preview?

    Posted 11 years ago on Friday May 25, 2012 | Permalink
  3. relish
    Member

    Hi Rob,
    Thanks for the quick reply. I've just checked it in the formbuilder preview and the results are the same: JS error and display set to none.

    The situation gets weirder. I've created a simple form with a dropdown field named Drop with Label=>Values of:
    First=>10, Second=>20, and Third=>30

    Then added a product field with the formula {Drop:1} and it works as expected!

    I then recreated my other form from scratch and the problem exists on that form too. I have a few dynamically populated fields and some conditional logic on some other fields. Please take a look at the XML export of the form here: http://www.pastie.org/3967375

    The filters used to populate the dynamic values can be found here: http://www.pastie.org/3967402

    Thanks for your help on this issue.

    Posted 11 years ago on Friday May 25, 2012 | Permalink
  4. This is what the form looks like from that XML in the pastie above: Screenshot

    Is this what you are seeing on load or are you getting display:none still?

    Posted 11 years ago on Friday May 25, 2012 | Permalink
  5. relish
    Member

    Ah so it looks like a plugin I have installed is interfering with how this works. The plugin is http://www.pedrolamas.com/projectos/jquery-lightbox-en/. After deactivating it, the form appears and is working fine. Thanks for checking out my form.

    For the other things, is it possible to enter in if/switch statements in the formula area? I would like to make the price dependent on the admission type (Regular or Student) and the attendance (single day or full conference). Also, I would like to add in price breaks for full day regular admissions based on the quantity requested. For example:
    - 1 - 4 People = $300 / person
    - 5 - 19 People = $275 / person
    - 20+ People = $225 / person

    Any ideas on how I can accomplish this?

    Posted 11 years ago on Friday May 25, 2012 | Permalink