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.

Calculations with GF

  1. I'm currently looking into purchasing GF for a job I'm currently working on but am unsure whether it will suit my needs at this stage. What I need to do is setup a multipage form that an end user will enter how many of each items listed they have and based on that number, multiple it by a preset amount to create a subtotal for that item and then add up all the sub totals for a grand total.

    An example would be that I have a list of items (say a desk, chair and a box) and an end user enters that they have 5 desks, 4 chairs and 2 draws. Each of these items need to have stored somewhere the exact cubic metres for those items. It should then be subtotaled per item (5 x cubic meters of 1 desk) and added all together (i.e. total cubic meters per item added together)

    Is this something that we can accomplish through gravity forms? I did read when I searched through the forums that in an upcoming release that you were supporting calculations but in the meantime is there anything that I'll be able to do to achieve this with gravity forms?

    Thanks

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  2. You can accomplish, but it will require some work. The amount of work required will be dependent on how many different items you have.

    One way to approach it would be to use values that correspond to each item. Let's say you have a list of items like this:

    desk [ QTY ]
    draw [ QTY ]
    chair [ QTY ]

    The visitor will enter the number of each item next to the corresponding.

    Then, after they submit the form, you will have to have some code to perform the calculations for you. The code will go in your theme's functions.php file and would likely use the gform_pre_submission hook.

    It can be accomplished and there are probably a couple different ways of doing it. There are no built in functions that will perform the calculations, but there are hooks available in Gravity Forms to process the submitted data. Please ask more questions before you purchase so we can better help you with your decision.

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  3. Thanks for that Chris. From what you have said it sounds very much like I can achieve what I need to even though it may take quite a bit of work (large number of items). There is one item I'd like to clarify. For each of those fields I create a quantity field for, is there a way to find out what the variables are called to retrieve that information before submission in that hook you mentioned? (basically so I can do the following: (get number of desks user entered) and multiply by 2.98 cubic meters).

    Thanks

    Posted 12 years ago on Monday January 9, 2012 | Permalink
  4. Yes, all data submitted via the form is available to you to process however you want, including calculations. You're right, it will require some work, but far less than writing an application completely. Gravity Forms will capture all the data, but it's up to you to process it, and there are hooks in place that allow you access to the data that was submitted.

    Posted 12 years ago on Monday January 9, 2012 | Permalink
  5. Stacey did you end up creating the form ? do you have a link to the form or wold you share the code how you made it ? I'm trying to make exactly that calculator ? greatly appreciate of you could tell me if gravity forms worked for your calculator :) thanks

    Posted 11 years ago on Saturday December 15, 2012 | Permalink
  6. You may be able to contact Stacey using the public information on her profile: http://www.gravityhelp.com/forums/profile/staceyfuller

    Posted 11 years ago on Monday December 17, 2012 | Permalink