Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

How to Hide WooCommerce In Stock Message from Product

WooCommerce show the quantity of product. Which will turn to out of stock message once you run out of quantity. Some store owners would prefer not to show the message. This can be useful when you sell custom made, or to order, goods that may not be in inventory until an order is place.

Let’s see How to Hide WooCommerce In Stock Message from Product.

Add this code in your theme’s functions.php file of your active child theme (or theme).

function hide_stock_message( $html, $text, $product ) {
	$availability = $product->get_availability();
	if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) {
		return '';
	}
	return $html;
}
add_filter( 'woocommerce_stock_html', 'hide_stock_message', 10, 3 );
Exit mobile version