-
-
Save ramiabraham/201703b264ffe0c04d61 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 | |
/** | |
* Disable commission on an entire product category in Easy Digital Downloads | |
*/ | |
function affwp_custom_wc_disable_commission_per_category( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) { | |
// Array of categories to disable commission for. Separate by a comma and use either the term name, term_id, or slug | |
$disabled_categories = array( 'category-one', 5 ); | |
// Disable commission if product exists in array of categories | |
if ( has_term( $disabled_categories, 'download_category', $product_id ) ) { | |
$referral_amount = 0.00; | |
} | |
return $referral_amount; | |
} | |
add_filter( 'affwp_calc_referral_amount', 'affwp_custom_wc_disable_commission_per_category', 10, 5 ); |
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 | |
/** | |
* Disable commission on an entire product category in WooCommerce | |
*/ | |
function affwp_custom_wc_disable_commission_per_category( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) { | |
// Array of categories to disable commission for. Separate by a comma and use either the term name, term_id, or slug | |
$disabled_categories = array( 'category-one', 5 ); | |
// Disable commission if product exists in array of categories | |
if ( has_term( $disabled_categories, 'product_cat', $product_id ) ) { | |
$referral_amount = 0.00; | |
} | |
return $referral_amount; | |
} | |
add_filter( 'affwp_calc_referral_amount', 'affwp_custom_wc_disable_commission_per_category', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment