WooCommerce 2.6 – Hide the “In stock” message on product page.

By default WooCommerce 2.6 always show the “In stock” and “Out of stock” messages on product pages.

The follow code helps you hide only the “In stock” message:

<?php
/**
* Hide the "In stock" message on product page.
*
* @param string $html
* @param string $text
* @param WC_Product $product
* @return string
*/
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 );

view raw
functions.php
hosted with ❤ by GitHub