Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Forked from amdrew/edd.php
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramiabraham/201703b264ffe0c04d61 to your computer and use it in GitHub Desktop.
Save ramiabraham/201703b264ffe0c04d61 to your computer and use it in GitHub Desktop.
<?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 );
<?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