I'm trying to filter the products shown in "related products" in woocommerce so that it only outputs related products that are in stock.
I've tried editing the "related.php" template as below - but it ain't working!
$args = apply_filters( 'woocommerce_related_products_args', array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'no_found_rows' => 1,
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $related,
'post__not_in' => array( $product->id ),
'meta-key' => '_stock_status',
'meta-value' => 'outofstock',
'compare' => '!='
) );
I'd appreciate any help
Many thanks