Description
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
Usage
<script type="text/javascript">
//Simply implement the function with name "gform_product_total" to activate the javascript filter.
function gform_product_total(formId, total){
//manipulate price here and return it
return price + 100;
}
</script>
Parameters
- formId
- (integer) The ID of the form in use.
- total
- (float) The total to be filtered.
Examples
This example adds $50 to the total price if the quantity field is greater than 100
<script type="text/javascript">
function gform_product_total(formId, total){
//only apply logic to form ID 165
if(formId != 165)
return total;
if(jQuery(".ginput_quantity").val() > 100)
total += 50;
return total;
}
</script>
Source Code
This filter is located in gravityforms.js