Created
December 11, 2015 03:34
-
-
Save amdrew/393d55c1a3d1c42d3103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very nice!