Description
JavaScript action hook that triggers when any pricing field is modified.
Usage
<script type="text/javascript"> jQuery(document).on('gform_price_change', function(event, productIds, htmlInput){ //do something }); </script>
Parameters
- event Event Object
Default JS event object. -
productIds object
The form id and the id of the product field. -
htmlInput string
The HTML input field.
Example
This example uses the gform_pre_render filter to load the hook.
add_action( 'gform_pre_render', 'do_price_stuff' ); function do_price_stuff( $form ) { ?> <script type="text/javascript"> jQuery(document).on('gform_price_change', function(event, productIds, htmlInput){ console.log(productIds); if (productIds['productFieldId'] == 1){ alert('Price updated'); } }); </script> <?php return $form; }
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.7.
Source Code
This filter is located in gformInitPriceFields() in js/gravityforms.js.