WooCommerce show the quantity of product. Which will turn to out of stock message once you run out of quantity. For several reasons a store owner might not want to show message that displays quantity of products left.
In this article we will show you how you can hide/remove in stock message from product page. Though before starting I will recommend you have a backup of your website.
Follow the guide given below:
- Before making the changes, your product would be appearing like shown below
- Go to Dashboard-> Appearance-> Editor
- On the right side of your screen you will see several functions open Theme Functions (functions.php)
- Paste the following code at the end of the functions file
function my_wc_hide_in_stock_message( $html, $text, $product ) { $availability = $product->get_availability(); if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) { return ''; } return $html; } add_filter( 'woocommerce_stock_html', 'my_wc_hide_in_stock_message', 10, 3 );
Now go to your store and open the product it will be shown without in stock message as shown below.
Thats All.
Thank you – quick, easy and worked exactly like it should! 😀
this worked brilliantly, thankyou id also like to hide the out of stock text message – do you have a solution 🙂