Redeem or exclude for specific Categories
To allow or prevent a gift card balance from paying for specific categoreis, use the pwgc_eligible_cart_amount hook. Category slugs can be found under Products > Categories inside your WordPress admin area.
Related articles
Redeem or exclude for specific products
Redeem or exclude for products that are on sale
Note: If you are more comfortable adding the code to your functions.php you can do that instead of using Code Snippets.
1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a new Snippet with the following code:
function custom_pwgc_eligible_cart_amount( $eligible_amount, $cart ) { // // Set this to the category slugs of the eligible products. Remove the values if all categories are eligible. // $eligible_categories = array( 'accessories', 'clearance' ); // // Set this to the category slugs of the ineligible products. // $ineligible_categories = array(); foreach( WC()->cart->get_cart() as $cart_item ) { $valid_product = true; if ( !empty( $ineligible_categories ) && has_term( $ineligible_categories, 'product_cat', $cart_item['product_id'] ) ) { $valid_product = false; } if ( !empty( $eligible_categories ) && !has_term( $eligible_categories, 'product_cat', $cart_item['product_id'] ) ) { $valid_product = false; } if ( !$valid_product ) { $eligible_amount -= $cart_item['line_total']; $eligible_amount -= $cart_item['line_tax']; } } return max( 0, $eligible_amount ); } add_filter( 'pwgc_eligible_cart_amount', 'custom_pwgc_eligible_cart_amount', 10, 2 );