gpecf_discount_total (PHP)

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


Modify the calculated discount for a Discount field.

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


Apply to all Discount fields on all forms.

add_filter( 'gpecf_discount_total', 'my_custom_function' );

Apply to all Discount fields on a specific form.

add_filter( 'gpecf_discount_total_FORMID', 'my_custom_function' );

Apply to a specific Discount field on a specific form.

add_filter( 'gpecf_discount_total_FORMID_FIELDID', 'my_custom_function' );


  • discount float

    The total for the current Discount field.

  • discount_field \GF_Field

    The current field object.

  • form array

    The current form object.

  • entry array

    The current entry object.


Manually Set Discount

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

add_filter( 'gpecf_discount_total', function( $discount, $discount_field ) {
	if ( $discount_field['id'] == 2 ) {
		$discount = -4;
	return $discount;
}, 10, 2 );


This filter is available since Gravity Forms eCommerce Fields 1.0.23.