I use the woocommerce / inventory menu settings to hide all of the “out of stock” products from category listings.
But there are some products them i want to display in certain categorys even is the stock is 0. Is there a function that can override the upper “main switch” in certain categorys?
Advertisement
Answer
Somehow I coudnt find it before, but here is the solution regarding to businessbloomer:
JavaScript
x
add_filter( 'pre_option_woocommerce_hide_out_of_stock_items', 'bbloomer_hide_out_of_stock_exception_category' );
function bbloomer_hide_out_of_stock_exception_category( $hide ) {
if ( is_product_category( 'specific-category' ) ) {
$hide = 'no';
}
return $hide;
}