gpecf_discount_total (PHP)
Description
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.
Usage
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' );
Parameters
Example
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 );
Since
This filter is available since Gravity Forms eCommerce Fields 1.0.23.