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.

Add Conditional Logic To Product Form

  1. I am trying to create a form to calculate a quote for a blinds website. This form has many conditional fields and the price is calculated based on user inputs.

    I have a price list which is in the matrix format. These have a width and a height field.
    If a customer enters width 20 and height 20 in the frontend the price changes to 200
    If a customer enters width 30 and height 30 in the frontend the price changes to 300
    If a customer enters width 40 and height 40 in the frontend the price changes to 400

    I would also like them to enter multiple entires at once on one page to capture multiple dimesions for multiple blinds in one form.

    For example

    Enter Width Blind 1 ____________ Enter height Blind 1 _______________
    Enter Width Blind 2 ____________ Enter height Blind 2 _______________
    Enter Width Blind 3 ____________ Enter height Blind 3 _______________

    Would You like to add more ? Click here

    Your total is $$xx

    Is this possible with gravity forms ? If yes I have a fair understanding of creating functions. Pointing in appropriate direction with a simple example would do.

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  2. Hi Anyone on this one ?

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  3. Do you have an example of this online now? How far have you gotten with it?

    It does not seem like you can use a list type field, because numbers are not one of the field types in a list (text or drop down select only), so I don't think the calculations would work.

    However, you could add multiple sections and display them with conditional logic. You might have 10 groups of fields for width and height, and only display one by default. Then, you could reveal another by having the user check a box "Add another" and that would be the condition for conditional logic to reveal the next set of width x height fields.

    Would that work?

    Posted 12 years ago on Wednesday October 17, 2012 | Permalink
  4. Hi Chris Thank you for your response.

    Example

    I did exactly as you mentioned. It worked great.
    Now I need to develop the logic that will look through the matrix to find a price.

    What is the best way of approaching this matrix price lookup issue ?

    I have gone ahead and converted the matrix from CSV into a DB table and inserted them using
    'ID' , 'Column' , 'Row' and 'Price'

    Now I would like to lookup a number a user enters for width and height say (600W and 700H) from the DB and output a price result.

    This number can be between a two numbers as well. For example DB has 600 , 700 , 800 , 900 and the customer could enter 632 and the function should roundup to the nearest row which is 700 in our case. Output the price for the value.

    Any ideas or pointers on where to get started.

    Posted 12 years ago on Wednesday October 17, 2012 | Permalink
  5. I like what you have done so far: looks good.

    Now, it looks like you are going to need to look up some pricing with gform_pre_submission. You want to be able to use the pricing in the email notification and possibly on the confirmation screen? And stored within the entry? If any of those are true, then gform_pre_submission is the place to do your lookup. http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    You will need a hidden field for each blind in your form, since that is where we are going to store the price of the blind. You have to have to have the field in the form, not visible to the user, so we have a place to store our price.

    The function you hook to the gform_pre_submission filter will have to connect to the database, retrieve the information you need, based on your rules, then return the correct data (ID, price?) I'm not sure how column and row correspond to width and height exactly, but this will all be part of the code you write to retrieve the information from the database.

    Posted 12 years ago on Thursday October 18, 2012 | Permalink