You can set discount rules by taxonomy, tag or attribute by using a filter. The example below shows you how to set a BXGY rule by product brand instead of category:
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 | |
/** | |
* Filter BXGY rule by brand taxonomy instead of category | |
*/ | |
function demo_bxgy_taxonomy( $taxonomy, $rule, $rule_id ) { | |
$taxonomy = 'product_brand'; // Change this to the taxonomy or tag of your choice | |
return $taxonomy; | |
} | |
add_filter( 'wcfad_validate_bxgy_rule_taxonomy', 'demo_bxgy_taxonomy', 10, 3 ); | |
function demo_bxgy_buy_categories( $buy_categories, $rule, $rule_id ) { | |
$buy_categories = array( 34 ); // This is the taxonomy term ID | |
return $buy_categories; | |
} | |
add_filter( 'wcfad_validate_bxgy_rule_buy_categories', 'demo_bxgy_buy_categories', 10, 3 ); | |
function demo_bxgy_get_categories( $get_categories, $rule, $rule_id ) { | |
$get_categories = array( 33 ); // This is the taxonomy term ID | |
return $get_categories; | |
} | |
add_filter( 'wcfad_validate_bxgy_rule_get_categories', 'demo_bxgy_get_categories', 10, 3 ); |