// Show the status for unmanaged stock products add_filter( 'woocommerce_get_availability', 'show_stock_status_for_unmanaged_products', 1, 2); function show_stock_status_for_unmanaged_products( $availability, $_product ) { // Don't do anything if managing stock if($_product->managing_stock()) return $availability; if($_product->is_in_stock()) : $availability['availability'] = __('In Stock', 'woocommerce'); $availability['class'] = ''; else : $availability['availability'] = __('Out of Stock', 'woocommerce'); $availability['class'] = 'out-of-stock'; endif; return $availability; }
The WooCommerce stock status (In Stock, Out of stock) will only show if WooCommerce is managing the stock for you. I was working on a project and the client wanted the ability to manually set if the product was in stock or not. The code snippet below will allow you to show the stock status for both managed and unmanaged products. Just copy and paste into your themes functions.php file.