How to Display Out of Stock Products in WooCommerce: A Complete Guide
Introduction:
By default, WooCommerce hides products that are out of stock from your online store. This approach has its merits, as it prevents customers from attempting to purchase items you can’t currently fulfill. However, there are scenarios where displaying out of stock products can be beneficial. For example, it can showcase product availability for backorder, gauge customer interest in particular items, or simply inform visitors that you do, in fact, carry that product even if it’s temporarily unavailable. Explore this article on Woocommerce How To Put A Product First In Product Page This article provides a comprehensive guide on how to show out of stock products in WooCommerce and the considerations you should make.
Main Part: Steps to Display Out of Stock Products
There are a few ways to display out of stock products in your WooCommerce store. We’ll explore the two most common methods: using the WooCommerce settings and using custom code.
Method 1: Using WooCommerce Settings
This is the simplest and most straightforward method, requiring no coding knowledge.
1. Navigate to WooCommerce Settings: In your WordPress dashboard, go to WooCommerce > Settings.
2. Click on the Products Tab: Once in the WooCommerce settings, select the Products tab.
3. Go to Inventory: Within the Products tab, click on the Inventory sub-tab.
4. Uncheck the “Hide out of stock items from the catalog” option: Locate the “Hide out of stock items from the catalog” option. By default, this checkbox is likely enabled. Uncheck this box.

5. Save Changes: Click the “Save changes” button at the bottom of the page.
After saving, your out of stock products should now be visible on your shop pages.
Method 2: Using Custom Code (Advanced)
For more control over *how* out-of-stock products are displayed, or if you want to selectively show/hide them based on categories or other criteria, custom code offers greater flexibility. Important: Be cautious when implementing custom code. Always back up your website before making changes.
1. Access Your Theme’s `functions.php` File: The recommended approach is to create a child theme and edit the `functions.php` file within your child theme. This ensures your customizations won’t be overwritten when the parent theme is updated. You can also use a code snippets plugin.
// Show out of stock products add_filter( 'woocommerce_product_is_visible', 'show_out_of_stock_products' );
function show_out_of_stock_products( $visible ) {
global $product;
if ( !$product->is_in_stock() ) {
$visible = true; // Set to true to display out of stock product
}
return $visible;
}
2. Add the Code Snippet: Copy and paste the provided code into your `functions.php` file. This code snippet filters the `woocommerce_product_is_visible` hook, which controls product visibility. It checks if a product is out of stock using `$product->is_in_stock()` and, if so, sets the `$visible` variable to `true`, effectively making the product visible.
3. Save Changes: Save the changes to your `functions.php` file.
4. (Optional) Add Visual Indicators: Simply showing out-of-stock products might be confusing. Consider adding visual indicators like “Out of Stock” badges, crossed-out prices, or a message stating when the product is expected to be back in stock. You can achieve this using CSS and, potentially, adding a little more code to `functions.php` to output the badge dynamically. For example, you could hook into `woocommerce_before_shop_loop_item_title` or `woocommerce_single_product_summary` to display a custom message.
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_out_of_stock_badge' );
function custom_out_of_stock_badge() {
global $product;
if ( !$product->is_in_stock() ) {
echo ‘Out of Stock‘;
}
}
Remember to add CSS to style the `.out-of-stock-badge` class to make it visually appealing.
Considerations When Displaying Out of Stock Products
- Clarity is Key: Ensure customers understand that the product is currently unavailable. Use clear “Out of Stock” messaging, badges, or labels. Be upfront about expected restock dates, if possible.
- Backorders: If you allow backorders, clearly indicate this on the product page. Explain the estimated delivery timeframe.
- Product Filtering and Sorting: Consider how out-of-stock products will impact your filtering and sorting options. You might want to offer options to sort by “availability” or filter to only show “in-stock” items.
- SEO Implications: While showing out-of-stock products might initially seem negative for SEO, Google understands that products go in and out of stock. Focus on providing a good user experience and clear messaging. You can also use structured data markup to indicate product availability.
- Abandoned Carts: Remind visitors to sign up for restock notifications. This can help you win back potential sales after an item is back in stock.
Conclusion:
Showing out of stock products in WooCommerce can be a valuable strategy for providing a transparent shopping experience and gauging customer demand. By carefully following the steps outlined Explore this article on How To Enable Email Verification In Woocommerce in this guide, you can easily display these products while ensuring customers are fully aware of their current availability. Remember to prioritize clear communication and implement visual indicators to prevent confusion and manage expectations effectively. Evaluate your specific business needs and customer behavior to determine the best approach for your online store. Finally, always test thoroughly after making any changes to your website.