<?php

/**
 * Disable AffiliateWP’s affiliate referral email if the referral amount is $0.00.
 *
 * @link https://andrew.dev/snippets/disable-affiliatewps-affiliate-referral-email-if-the-referral-amount-is-0-00/
 *
 * @param boolean $send_email Whether or not to send the email to the affiliate.
 * @param object $referral The referral object.
 *
 * @return boolean $send_email Whether or not the email will be sent to the affiliate.
 */
function affwp_custom_disable_affiliate_referral_email( $send_email, $referral ) {

	// Disable the email if the referral amount is 0.00.
	if ( '0.00' === $referral->amount ) {
		$send_email = false;
	}

	return $send_email;

}
add_filter( 'affwp_notify_on_new_referral', 'affwp_custom_disable_affiliate_referral_email', 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *