Fires right before updating the Total value for forms with pricing fields. Allows users to implement custom logic to manipulate the Total value.

NOTE: This hook only applies to the form front end javascript, and will only change the display of the Total. You must also implement the gform_product_info to make sure the total is displayed properly in the entry pages and sent properly to third party services via Add-Ons such as the PayPal Add-On

The best location to put this javascript code is by adding an HTML field to your form and place the javascript code in that field, wrapped with the script tags.

An alternative placement is to put the javascript in the gform_pre_render hook.


gform.addFilter( 'gform_product_total', function(total, formId){
    // do something with the total
    return total;
 } );


  • total float

    The total to be filtered.

  • formId integer

    The ID of the form in use.


1. Add a value to the total

This example adds $50 to the total price if the quantity field is greater than 100

<script type="text/javascript">

    gform.addFilter( 'gform_product_total', function(total, formId){
        //only apply logic to form ID 165
        if(formId != 165)
            return total;

        if(jQuery(".ginput_quantity").val() > 100)
            total += 50;

        return total;
    } );


2. Prevent totals less than zero

// prevent the total being less than zero
gform.addFilter( ‘gform_product_total’, function (total, formId) {

return total < 0 ? 0 : total; } ); [/php]

Source Code

This filter is located in gravityforms.js