Code-Snippets-Functions/Execute a function on a child site/AffiliateWP/disable-zero-amount-affiliate-referral-emails
2020-07-30 15:26:44 -06:00

19 lines
651 B
Text

function affwp_check_for_zero_amount_referral_disable_email( $return, $referral ) {
// Check to see if AffiliateWP is active.
if ( ! function_exists( 'affiliate_wp' ) ) {
return;
}
// Get the referral amount from the referral object passed in.
$referral_amount = $referral->amount;
// Check of the referral amount is zero, will be formatted to a string.
if ( $referral_amount == '0.00' ) {
// Disables the "New Referral Email" sent to the affiliate if the amount of the referral is zero.
$return = false;
}
return $return;
}
add_filter( 'affwp_notify_on_new_referral', 'affwp_check_for_zero_amount_referral_disable_email', 10, 2 );