//this is how i added AND filter on product tags
function product_tag_and_filter( $query ) {
if ( is_admin() || ! $query->is_main_query() ){
return;
}
if(is_product_category()){
$tax_query = array();
// add meta_query elements
if( !empty( get_query_var( 'product_tag' ) ) ){
foreach(get_query_var( 'product_tag' ) as $val){
$tax_query[] = array( 'taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $val , 'compare' => '=' );
}
}
if( count( $tax_query ) > 1 ){
$tax_query['relation'] = 'AND';
}
if( count( $tax_query ) > 0 ){
$query->set( 'tax_query', $tax_query );
}
}
}
add_action( 'pre_get_posts', 'product_tag_and_filter', 1 );