Is it possible to hide a product category based on the products stock status?
Question
I would like to ask if it is possible to hide a category from my shop based on the factor that this category does not contain even 1 product that is in stock. If even 1 product is in stock then the category will appear.
I tried something like the code below with no avail
function hide_out_of_stock_categories( $list_args ){
if ( ! $product->managing_stock() && ! $product->is_in_stock() ){
$list_args[ 'hide_empty' ] = 1;
return $list_args;
}
}
I need to search first for the products inside the category and then check if the product stock status, but I am missing something here.
0
2 years
2020-12-22T16:10:27-05:00
2020-12-22T16:10:27-05:00 0 Answers
6 views
0
Leave an answer