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.

Using Rounding for Calculations

  1. Is there a way using the new Enable Calculations box to round to nearest variable number? For example the next increment of 10. So if someone were to enter the number 2 it would round to 10. We love the new features of GF, please let us know if this is possible. Thank you!

    Posted 11 years ago on Wednesday May 2, 2012 | Permalink
  2. If this can't be done, let me explain what I'm trying to accomplish. We sell a certain service and when a user enters a quantity between 1-10 the price is X. If they enter between 11-20 the price is X+5. Anyone know if this is possible?

    Posted 11 years ago on Thursday May 3, 2012 | Permalink
  3. This hook will solve for what you are trying to do.

    http://www.gravityhelp.com/documentation/page/Gform_product_total

    Try it out and let us know if you run into any issues.

    Posted 11 years ago on Thursday May 3, 2012 | Permalink
  4. Rob,

    Thank you for that hook the code now works on the front end of the site. However I am running into issues having the new total show up in notifications. Do I need to use the gform_product_info filter? If so I'm not understanding how it works. Here is the working Javascript code.

    function gform_product_total(formId, total){

    standardrecord = jQuery("#input_2_14").val()*1;
    legalrecord = jQuery("#input_2_19").val()*2;
    quantity = (standardrecord + legalrecord);

    if (quantity > 0) if (quantity <= 100)
    {
    return 40;
    } }

    How would I write this same code so that it will show up in notifications?

    Posted 11 years ago on Tuesday May 8, 2012 | Permalink
  5. Hello Gary,
    Yes, you will need to use the gform_product_info hook (http://www.gravityhelp.com/documentation/page/Gform_product_info). Following is a code snippet to point you in the right direction.

    add_filter("gform_product_info", "change_price", 10, 3);
    function change_price($product_info, $form, $lead){
    
    	//NOTE: change this so that it loops through the products and finds the appropriate one
        $quantity = $product_info["products"][1]["quantity"];
        if($quantity < 100)
            $product_info["products"][1]["price"] = 40;
    
        return $product_info;
    }
    Posted 11 years ago on Wednesday May 9, 2012 | Permalink
  6. Perfect, thank you!

    Posted 11 years ago on Monday May 14, 2012 | Permalink

This topic has been resolved and has been closed to new replies.