How to Hide Out of Stock Products in WooCommerce

How to Hide Out of Stock Products in WooCommerce

If you operate an online store using WooCommerce, managing product inventory is a critical aspect of maintaining customer satisfaction and optimizing sales. In this guide, we’ll explore the importance of hiding out-of-stock products and provide a step-by-step walkthrough on how to hide Out of Stock Products in WooCommerce store.

Why Hiding Out of Stock Products is Important

Enhanced Customer Experience:

    • Avoids disappointment and frustration
    • Streamlines the shopping process for efficient customer experience

Professional Appearance:

    • Maintains a polished image and organized storefront
    • Prevents confusion and contributes to a positive perception of the business

Search Engine Optimization (SEO):

    • Improves search engine rankings by offering a focused and relevant product selection
    • Reduces bounce rates, indicating a more engaging website for users

Inventory Management:

      • Facilitates accurate inventory tracking for effective management
      • Prevents backorders, ensuring timely fulfillment of orders and customer satisfaction

How to Hide Out-of-Stock Products in WooCommerce|4 Ways

1. Using WooCommerce Settings

Utilizing WooCommerce’s built-in settings is the easiest method. By accessing the “Out of stock visibility” option in WooCommerce settings, you can automatically hide out-of-stock products from your catalog, shop page, and search results. This ensures a seamless and efficient way to manage product visibility.

  • Navigate to WooCommerce > Settings > Products > Inventory in your WordPress dashboard.
  • Check the “Out of stock visibility” box under “Hide out of stock items from the catalog.”

How to Hide Out of Stock Products in WooCommerce

  • Save changes to automatically hide out-of-stock products.

2. Hide Specific Out of Stock Products from your Store

Sometimes, you may want to selectively hide specific out-of-stock products while keeping others visible. This technique allows you to hide individual products that are temporarily unavailable, such as seasonal or limited edition items. It provides flexibility in managing the visibility of specific products based on your store’s unique needs.

  • Visit Products > All Products in the WordPress dashboard.
  • Locate the desired product, click Edit, and find the Catalog Visibility option in the Publish box.
  • How to Hide Out of Stock Products in WooCommerceSet visibility to “Hidden” and update the product. How to Hide Out of Stock Products in WooCommerce

3. Using Plugins to Stop Out of Products from Showing

For those seeking more control over product visibility and additional features, plugins like WooCommerce Better Variations offer a comprehensive solution. These plugins allow you to customize the display of out-of-stock variations, change labels, and set back-in-stock dates. While these plugins may be paid, they provide a range of functionalities beyond just hiding out-of-stock products.

If you wanna change out-of-stock text, check our separate guide here.

  • Choose a plugin like WooCommerce Better Variations and install and activate it.
  • Access plugin settings (WooCommerce > Settings > Products > Better Variations) to customize the display of out-of-stock variations. How To Hide Out Of Stock Products In WooCommerce
  • Utilize features such as disabling out-of-stock variations, changing text labels, or specifying back-in-stock dates. How to Hide Out of Stock Products in WooCommerce How to Hide Out of Stock Products in WooCommerce

4. Using PHP Code Snippets to Hide Out of Stock Products

This method is tailored for advanced users comfortable with coding. By adding PHP code snippets to your site’s functions.php file or using a dedicated plugin, you gain the ability to hide out-of-stock products selectively. This technique allows for fine-grained control, enabling you to customize the hiding process based on different sections of your store, such as the homepage, search results, or related products.

  • For advanced users, implement PHP code snippets in the functions.php file or use a plugin like Code Snippets.
  • Examples include hiding simple or variable products from the catalog, search results, homepage, or related products section.
  • You can hide out-of-stock products from the catalog using the following code in the functions.php file:

If you don’t know how to edit functions.php file then click here.

// Hide out of stock products from catalog
add_action( 'pre_get_posts', 'hide_out_of_stock_products' );

function hide_out_of_stock_products( $query ) {
if ( ! $query->is_admin && $query->is_main_query() && ( $query->is_post_type_archive( 'product' ) || $query->is_tax( get_object_taxonomies( 'product' ) ) ) ) {
$meta_query = $query->get( 'meta_query' );
if ( ! is_array( $meta_query ) ) {
$meta_query = array();
$meta_query[] = array(
'key' => '_stock_status',
'value' => 'outofstock',
'compare' => '!=',
$query->set( 'meta_query', $meta_query );

Always back up your site before making any code changes.

FAQ (How to Hide Out of Stock Products in WooCommerce)

What is product visibility in WooCommerce?

Product Visibility by Country for the WooCommerce plugin lets you show/hide WooCommerce products depending on the customer’s country. The customer’s country is detected automatically by IP. There are options in the plugin to hide products by Hiding catalog visibility – will hide selected products in the shop and search results.

How can I hide out-of-stock products in WooCommerce?

To hide out-of-stock products, navigate to WordPress Dashboard > Settings > Products > Inventory and enable the “Hide out-of-stock items from the catalog” option.

Is it possible to hide specific out-of-stock products while keeping others visible?

Yes, you can individually hide specific out-of-stock products by setting the product’s catalog visibility to “Hidden” on the product edit page.

What if I want to keep out-of-stock products visible but change their labels?

Use PHP code snippets to modify the out-of-stock label. For example, change the label to “Coming Soon” using the provided code snippet.

Can I notify customers when a previously out-of-stock product becomes available again?

Consider using the Back In Stock Notifications plugin by WooCommerce. This plugin allows customers to subscribe to emails informing them when a previously out-of-stock product is back in stock.

What is product visibility by user roles in WooCommerce?

The WooCommerce Product Visibility by User Role plugin allows store administrators to make the shop’s products visible and invisible for different user roles. With it, you can hide the visibility of products from shop pages, search results, single product pages, and product widgets through your eCommerce store.


Hiding out-of-stock products in WooCommerce is a strategic move to enhance the user experience, prevent customer loss, and boost sales. Whether using built-in settings, individual product adjustments, plugins, or PHP code snippets, implementing these methods ensures a more focused and visually appealing online shopping environment. Choose the method that aligns with your store’s needs and enjoy a streamlined WooCommerce experience.