edd-library icon indicating copy to clipboard operation
edd-library copied to clipboard

Update adjust-rate-for-referrals.html code

Open mihaijoldis opened this issue 3 years ago • 1 comments
trafficstars

That code will most likely no longer work as we use custom tables now for commissions. Needs a rewrite to get the data correctly from the DB.

mihaijoldis avatar Mar 10 '22 11:03 mihaijoldis

This is the code snippet that @tubiz provided so that a commission is not recorded if the purchase was a referral

function affwp_eddc_restrict_commission( $commissions_calculated, $payment ) {

	if ( ! function_exists( 'affiliate_wp' ) ) {
		return $commissions_calculated;
	}

	$referral = affiliate_wp()->referrals->get_by_with_context( 'reference', $payment->ID, 'edd' );

	if ( ! empty( $referral ) ) {
		return array();
	}

	return $commissions_calculated;
}
add_filter( 'eddc_commissions_calculated', 'affwp_eddc_restrict_commission', 10, 2 );

mihaijoldis avatar Mar 10 '22 13:03 mihaijoldis