By default, WooCommerce doesn’t display the “in stock” status or availability on the product page. While this is an expected standard for online shoppers these days I am still surprised why this is the case. Since I found the solution, I wanted to share it with you since I know you’re not the only one who will find this little WooCommerce modification useful.
Why Show an “In Stock” Message?
“In Stock” or “Out of Stock”, which ever the case may be, showing the availability status even if you never, ever run out of stock in an item helps conversion rates because it provides a signal to the customer that it is in fact in stock. Whether or not you decide to show how many are available or show low stock quantities, a simple, “In Stock”, can be the most helpful thing when shopping online.
Here’s How to Show “In Stock”
- In your WordPress admin, navigate to Appearance > Editor.
- Click functions.php on the right.
- Go to the bottom of the file and paste the following code then save.
// Hook in
add_filter( 'woocommerce_get_availability', 'custom_override_get_availability', 10, 2);
// The hook in function $availability is passed via the filter!
function custom_override_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) $availability['availability'] = __('In stock', 'woocommerce');
return $availability;
}
Is Your Product In Stock?
Let me know if this worked for you or if you found another way how to do this.
Leave a Reply