Site logo

Archived topic

I am trying to hide "in stock" from the product front end page

3 replies · Started by Adrien on July 22, 2020

Viewing posts 1–4 of 4

Dear Generatepress Team,

I need your help. I m trying to hide "in stock" from showing on the product front end page.
Here an image: https://snipboard.io/u2fDK0.jpg

I went in the back end following some other support tickets and set this:https://snipboard.io/0mdT3E.jpg

However "in Stock" still shows. I hope you can help me to hide this.

Thank you very much in advance. Best, Adrien.

Hi there,

try this PHP snippet:

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 );

Thank you very much David. It worked!
In fact, I had this already but while reading the other posts I thought I didn't need the Snippet and that there was a back end option to do it.

I think the individual product stock settings can override that general setting - not sure as Woo does some mysterious things ...

This archived topic is closed to new replies.