Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

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. For several reasons a store owner might not want to show message that displays quantity of products left.

In this article we will show you how you can hide/remove in stock message from product page. Though before starting I will recommend you have a backup of your website.

Our team at Themelocation is comprised of WordPress developers of high expertise

  • We can maintain, support and manage your single, or all your clients, website with dedication
  • Our skills are at your disposal.

Book a Call

Follow the guide given below:

  • Before making the changes, your product would be appearing like shown below

  • Go to Dashboard-> Appearance-> Editor
  • On the right side of your screen you will see several functions open Theme Functions (functions.php)
  • Paste the following code at the end of the functions file
function my_wc_hide_in_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', 'my_wc_hide_in_stock_message', 10, 3 );

Now go to your store and open the product it will be shown without in stock message as shown below.

Thats All.

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

1 thought on “How to Hide WooCommerce In Stock Message from Product?”

Leave a Comment

Your email address will not be published. Required fields are marked *