WooCommerce – show “Out of stock” text on products

Content Views Pro helps you to show WooCommerce products in grid and list layout easily.
For products which you don’t have in stock anymore, you might want to show the “Out of stock” text. To do that, please add this code to file functions.php in the theme’s folder (or install this plugin Code Snippets then add this code to the “Code” textarea):

// Content Views Pro - Woocommerce: Display Out of Stock badge
add_action( 'pt_cv_item_extra_html', 'cvp_item_extra_html_wofs' );
function cvp_item_extra_html_wofs( $post_id ) {
	$product = wc_get_product( $post_id );
	if ( is_object( $product ) ) {
		if ( !$product->is_in_stock() ) {
			echo '<div class="out-of-stock">Out of stock</div>';
		}
	}
}

Best regards,