Disable the “In Stock” Message on WooCommerce Products

Posted on by Dan Pock
Reading Time: 2 minutes

Lets say you have an eCommerce business selling customized coffee mugs. Each mug you sell gets a custom message printed on it and you just fill the orders as they come in. You know each mug gets customized before shipping out, so you don't really need to track the inventory.

If you happen to run out of your local stock of blank mugs then you'll just buy a new box, no big deal. In a case like this you may track inventory, but don't actually need WooCommerce to report this. So how can you hide the 'In Stock' message on your product pages?

How do I hide the “In Stock” message on my product pages?

Some store owners would prefer not to show the “In Stock” 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.

Making sure your catalog of products doesn’t display the “In Stock” message is as simple as adding a code snippet to your site’s functions.php file.

WordPress Code Warning: This article features code changes, or snippets, that you can make in your active themes function.php file. If you are unfamiliar with this task, or want to brush up, we have an article on Managing code snippets in WooCommerce. The technique provided can be used for both WordPress and WooCommerce sites.
 * Hide the "In stock" message on product page.
 * @param string $html
 * @param string $text
 * @param WC_Product $product
 * @return string
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 );

Keep in mind that you should never make code changes on your production site. You should always test code changes like this in a local, or development, version of your site first. That way if something goes wrong your customers won't see any errors.

Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions Team or an experienced Hosting Advisors today!

About the Author: Dan Pock

Dan Pock does technical support at Liquid Web with a background in System Administration, Public Relations, and Customer Service. His favorite things include his cats, Oscar Boots, and Dash Nougat; experimenting with PHP; and making up recipes (or at least attempting to). You can find his coding hijinks on GitHub, where he shares most of his projects and open source work.

Latest Articles

How to Set Up a Cron Job in cPanel

Read Article

How to Set Up a Cron Job in cPanel

Read Article

What Is Puppet Software and How Do You Use It?

Read Article

Accessing Man Pages on Ubuntu 16.04 LTS

Read Article

What is VMware Fusion?

Read Article