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.
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;
}
Example
This example uses the gform_pre_render filter to load the hook.
Placement
Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.
See also the JavaScript/jQuery section in this article: Where Do I Put This Code?
Since
This filter was added in Gravity Forms version 1.7.
Source Code
This filter is located in gformInitPriceFields() in js/gravityforms.js.