Last active
April 5, 2023 13:51
-
-
Save plugin-republic/4f4bc5a429d4a5c56cee196f999841f2 to your computer and use it in GitHub Desktop.
This file contains 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 bulk discount rules by taxonomy instead of product category | |
*/ | |
function prefix_validate_bulk_rule_taxonomy( $tax, $rule, $rule_id ) { | |
$tax = 'product_brand'; | |
return $tax; | |
} | |
add_filter( 'wcfad_validate_bulk_rule_taxonomy', 'prefix_validate_bulk_rule_taxonomy', 10, 3 ); | |
function prefix_validate_bulk_rule_buy_categories( $buy_categories, $rule, $rule_id ) { | |
if( $rule_id == 0 ) { | |
// This rule is Pricing Rule #1 - the $rule_id starts at 0 but our Pricing Rules start at 1 | |
$buy_categories = array( 32 ); // Replace this with the IDs of the brand terms for this rule | |
} else if( $rule_id == 1 ) { | |
// This rule is Pricing Rule #2 | |
$buy_categories = array( 33 ); // Replace this with the IDs of the brand terms for this rule | |
} | |
return $buy_categories; | |
} | |
add_filter( 'wcfad_validate_bulk_rule_buy_categories', 'prefix_validate_bulk_rule_buy_categories', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment