I would like to show only "in stock" related products on WooCommerce single product pages.
I know I can override single-product/related.php template file via My theme. Here below is the related code for this template:
<section class="related products">
<h2><?php _e( 'You May Also Want', 'MyStore' ); ?></h2>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $related_products as $related_product ) : ?>
<?php
$post_object = get_post( $related_product->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object );
wc_get_template_part( 'content', 'product' ); ?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</section>
Is it possible making some changes to this file to only show "in stock" related products on WooCommerce single product page? Any help is appreciated.