Exclude products from multiple taxonomies

  php, woocommerce

On the Woocommerce Shop page there are 2 working taxonomies: product_cat and season

What I try to do is to exclude from the query tax season, sale items, but because it also has a product_cat trousers which is also used in the query for the shop page, it still shows it in the query:

add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );  
function custom_pre_get_posts_query( $q ) {
        $tax_query = (array) $q->get( 'tax_query' );
        $tax_query[] = 
            array(
               'taxonomy' => 'season', // taxonomy
               'field' => 'slug',
               'terms' => array( 'sale' ), //slug taxonomies
               'operator' => 'NOT IN'
            );
        $q->set( 'tax_query', $tax_query );
}

So how do I exclude this, but by keep having the trousers product_cat assigned? Is there a && option possible in above function?

Source: Ask PHP

LEAVE A COMMENT