Skip to content

Instantly share code, notes, and snippets.

@amdrew
Created December 11, 2015 03:34
Show Gist options
  • Save amdrew/393d55c1a3d1c42d3103 to your computer and use it in GitHub Desktop.
Save amdrew/393d55c1a3d1c42d3103 to your computer and use it in GitHub Desktop.
<?php
function affwp_edd_block_commission_unless_purchased( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// get referring affiliate ID
$affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
// get user ID of referring affiliate
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
if ( ! ( function_exists( 'edd_has_user_purchased' ) && edd_has_user_purchased( $user_id, array( $product_id ) ) ) ) {
$referral_amount = 0.00;
}
return $referral_amount;
}
add_filter( 'affwp_calc_referral_amount', 'affwp_edd_block_commission_unless_purchased', 10, 5 );
@michaelbeil
Copy link

very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment