Last active
October 17, 2017 09:08
-
-
Save codelion7/71787af8dedceebe611612cbf4a0cb77 to your computer and use it in GitHub Desktop.
AffiliateWP MLM - Apply a 30% Direct Commission Rate for Affiliates without Sub Affiliates
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
/** | |
* Apply a 30% direct commission rate for affiliates without Sub Affiliates | |
*/ | |
function affwp_mlm_get_non_parent_rate( $rate, $affiliate_id, $type, $reference ) { | |
// If a per-affiliate rate is set, use that | |
if ( affiliate_wp()->affiliates->get_column( 'rate', $affiliate_id ) ) { | |
return $rate; | |
} | |
// Stop if the affiliate has sub affiliates | |
if ( affwp_mlm_is_parent_affiliate( $affiliate_id ) ) { | |
return $rate; | |
} else { | |
$rate = 30; // The non-parent rate to apply | |
// Format percentage rates | |
$rate = ( 'percentage' === $type ) ? $rate / 100 : $rate; | |
} | |
return $rate; | |
} | |
add_filter( 'affwp_get_affiliate_rate', 'affwp_mlm_get_non_parent_rate', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment