The thing I want to accomplish is the following. In WooCommerce 3.9, Whenever I use the shortcode [product_category category="jeans"] or any other category I want it to show products of this category except the products which are out of stock
I know I can change the setting to hide all out of stock product in WooCommerce, but I want them to be shown at all places (archive, shop, widgets) except when I use the shortcode
I've tried codes like the one below (which i assume only works for [products category="jeans"] ) So that would also be an option
add_filter( 'woocommerce_shortcode_products_query' , 'tryout_exclude_oos_shortcodes');
function tryout_exclude_oos_shortcodes($query_args){
$query_args['tax_query'] = array(array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => array('outofstock'),
'compare' => 'NOT IN',
));
return $query_args;
}
At this moment I tried a lot, but my knowledge doesn't is limited at the moment. Is what I'm asking even possible and so.. what am I missing?