How to remove out of stock products in woocommerce

How to Remove Out of Stock in WooCommerce

Managing an online store requires creating a hassle-free shopping experience for your customers. When out-of-stock products are displayed, it can cause disappointment, missed sales opportunities, and even harm your brand’s reputation.

By hiding or removing these items, you can keep your store well organized, make it easier for customers to browse, and direct their attention to products they can actually buy.

To remove out-of-stock products in WooCommerce, go to WooCommerce > Settings > Products > Inventory in your WordPress dashboard. Check the box for hide out-of-stock items from the catalog and save the changes. This simple tweak ensures that unavailable products no longer appear on your shop or category pages.

In this blog, we’ll cover 3 ways to remove out-of-stock products in Woocommerce,

  • Hide out-of-stock products using built-in settings,
  • Manually remove out-of-stock products,
  • Remove out-of-stock products programmatically

Why remove out-of-stock products in WooCommerce?

Out-of-stock products can clutter your store, create unnecessary clicks for shoppers, and potentially harm your conversion rates. By removing or hiding these items, you can:

  • Enhance User Experience: Prevent customers from encountering unavailable products.
  • Streamline Store Navigation: Keep your product pages clean and relevant.
  • Improve SEO and Analytics: Focus search engine crawlers on active products, improving indexation and analytics insights.

Now, let’s dive into the methods.

Method 1: Hide Out-of-Stock Products in WooCommerce Settings

The simplest way to remove out-of-stock items is through WooCommerce’s built-in settings. Your stocked-out products won’t be permanently deleted; they will be just hidden. And you can make them visible anytime when your stock is updated.

Steps to hide stock-out products in Woocommerce:

Step 1: Access WooCommerce Inventory Settings:

  • Log in to your WordPress admin dashboard.
  • Navigate to WooCommerce > Settings > Product > Inventory tab.
Access WooCommerce Inventory Settings

Step 2: Enable Stock Management

  • Ensure the “Enable stock management” option is checked.
  • Check the box of Enable out of stock notifications to get alerts when your products are stocked out from your Woocommerce store.
Enable Stock Management

Step 3: Hide out of stock products in Woocommerce

  • Scroll down to check the option “Hide out-of-stock items from the catalog.”
  • Save the changes.
Hide out of stock products

All the out-of-stock items will no longer appear on your shop pages, search results, or category listings.

Method 2: Manually Remove Out-of-Stock Products in Woocommerce

If you prefer to remove specific out-of-stock products from your Woocommerce, follow these steps:

Step 1: Go to Your Woocommerce Product List

  • From the WordPress dashboard, navigate to Products > All Products.
Go to Your woocommerce Product List:

Step 2: Filter Out-of-Stock Items:

  • Go to the Filter by stock status and click on out-of-stock option.
  • Then, hit on Filter.
Filter Out-of-Stock Items

Step 3: Delete stock-out Products

  • Select the items you want to remove. To bulk remove all the stock-out products, check the first box to select altogether.
  • In the bulk actions dropdown, select move to trash.
  • Hit Apply to save the changes.
Delete stock-out Products

So, your stock-out products are removed from your Woocommerce store.

Method 3: Remove Out-of-Stock Products in WooCommerce Programmatically

If you prefer a hands-on approach or want more control over how out-of-stock products are managed, removing them programmatically is an excellent option. This method involves adding custom code to your WooCommerce store, which automatically hides or removes out-of-stock products from the shop and catalog pages.

Step-by-Step Guide to Remove Out-of-Stock Products Programmatically

Step 1: Access the Theme File Editor

  • In your WordPress dashboard, navigate to Appearance > Theme File Editor.
  • Open the functions.php file of your active theme.

Step 2: Add the Custom Code

  • Copy and paste the following code snippet into the functions.php file:
// Remove out-of-stock products from WooCommerce shop and catalog

add_action('pre_get_posts', 'hide_out_of_stock_products');

function hide_out_of_stock_products($query) {

    if (!is_admin() && $query->is_main_query() && (is_shop() || is_product_category() || is_product_tag())) {

        $meta_query = $query->get('meta_query');

        if (!is_array($meta_query)) {

            $meta_query = [];

        }

        $meta_query[] = [

            'key' => '_stock_status',

            'value' => 'outofstock',

            'compare' => '!='

        ];

        $query->set('meta_query', $meta_query);

    }

}

Step 3: Save the Changes

  • After pasting the code, click Update File to save your changes.
remove out of stock products with custom code

Step 4: Test the Functionality

  • Visit your shop or category pages to confirm that out-of-stock products are no longer visible.
  • Update a product’s stock status to “Out of Stock” and refresh the page to ensure it is removed.

Additional Tips for Managing Woocommerce Out-of-Stock Inventory

  • Enable Stock Synchronization: If you’re using third-party tools, ensure stock levels sync in real time.
  • Use Conditional Logic: Implement rules for product visibility based on user roles or purchase history.
  • Optimize Product Pages: Add custom messages or redirect users to similar products when stock is unavailable.

FAQs:

How do I turn off the out-of-stock notification in WooCommerce?


1. Go to WooCommerce > Settings > Inventory.
2. Uncheck “Enable low stock notifications” and “Enable out-of-stock notifications.”

Can I display “Out of Stock” products in a separate category?


Yes, you can create a custom category for out-of-stock products and assign them manually or via a plugin like Advanced WooCommerce Categories.

How do I set inventory thresholds in WooCommerce?


1. Navigate to Products > Inventory in WooCommerce settings.
2. Set the “Low stock threshold” and “Out of stock threshold” values.

What are the best plugins to manage stock in WooCommerce?


1. Stock Manager for WooCommerce
2. WP Inventory Manager
3. WooCommerce Product Stock Alert

Conclusion

When you remove out-of-stock products in WooCommerce, it is essential for maintaining a user-friendly and efficient online store. Whether you choose built-in settings or custom code, each method has its own unique benefits. Evaluate your store’s needs and pick the solution that best suits your workflow. A clean, optimized store can lead to improved customer satisfaction and better sales performance.

Related Articles:

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

6,390,033+ Downloads. 637+ plus 5-star ratings. Promote products on any platform you want.