gpecf_discount_total (JS)

  1. Description
  2. Usage
  3. Parameters
  4. Example
  5. Manually Set Discount
  6. Since

Description

Modify the calculated discount for a Discount field.

This filter must be used with its PHP counterpart to handle filtering the discount amount on submission.

Usage

gform.addFilter( 'gpecf_discount_total', 'my_custom_function' );

Parameters

  • discount float

    The total for the current Discount field.

  • $field object

    The jQuery object for the current Discount field.

Example

Manually Set Discount

Manually set the discount for Field ID 2 to -$4.00.

gform.addFilter( 'gpecf_discount_total', function ( discount, $field ) {
	if ( $field[0].name == "input_2" ) {
		discount = -4;
	}
	return discount;
} );

Since

This filter is available since Gravity Forms eCommerce Fields 1.0.23.