Hide Out Of Stock Products On Brand Page
-
Hello,
Hoping someone here can help! I am trying to hide out of stock products everywhere except for one category called “sold-archives”
The code below successfully achieves that, however the out of stock products still show up on the “brands” pages. Does anyone know how I might amend the code below to include Berocket brand pages? I tried adding another && !is_product_brands() or other variations but it causes a critical error.
I would be so appreciative of anyone who has an idea on how to include the brand pages in this.
add_filter( 'woocommerce_product_query_tax_query', 'vg_hide_out_of_stock_products' ); function vg_hide_out_of_stock_products( $tax_query ) { if( !is_shop() && !is_product_category() && !is_product_tag() ) { return $tax_query; } if( is_product_category('sold-archives') ) { $tax_query[] = array( 'taxonomy' => 'product_visibility', 'field' => 'slug', 'terms' => ['outofstock'], 'operator' => 'IN', ); } else { $tax_query[] = array( 'taxonomy' => 'product_visibility', 'field' => 'slug', 'terms' => ['outofstock'], 'operator' => 'NOT IN', ); } return $tax_query; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Hide Out Of Stock Products On Brand Page’ is closed to new replies.