Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Last active April 5, 2023 13:51
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 plugin-republic/4f4bc5a429d4a5c56cee196f999841f2 to your computer and use it in GitHub Desktop.
Save plugin-republic/4f4bc5a429d4a5c56cee196f999841f2 to your computer and use it in GitHub Desktop.
<?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