Hide loop read more buttons for out of stock items in WooCommerce

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme.

/**
 * Hide loop read more buttons for out of stock items 
 */
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
	function woocommerce_template_loop_add_to_cart() {
		global $product;
		if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;
		wc_get_template('loop/add-to-cart.php');
	}
}
jannell_thanh@mailxu.com trovinger.florencia rodina.selina@mailxu.com