gform_price_change

Description

JavaScript action hook that is triggered when any pricing field is modified.

Note: This event was replaced by the gform-products-product_field_changed event in Gravity Forms 2.9.1.

Usage

document.addEventListener('gform_price_change', function(event) {
    var productIds = event.detail.productIds;
    var htmlInput = event.detail.htmlInput;
    
    // Do something with productIds and htmlInput
    console.log(productIds);
});

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

Detecting Product Price Change

document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('gform_price_change', function(event) {
        var productIds = event.detail.productIds;
        var htmlInput = event.detail.htmlInput;

        console.log('Price changed for product field IDs:', productIds);

        // Example: Check if the price change is for Product Field ID 1
        if (productIds.indexOf(1) !== -1) {
            alert('The price for Product 1 has been updated!');
        }
    });
});

Placement

Reference the article Adding JavaScript Code to the Frontend of Your Site.

Since

This filter was added in Gravity Forms version 1.7.

Source Code

This filter is located in gformInitPriceFields() in js/gravityforms.js.