I have a site which needs to display the available stock left for each product, which is fine. However some products are print on demand (i.e. infinite stock) so I have these loaded with 99999999 in stock. Obviously I don't want this stock level to show on the front end of the site as there isn't really any physical stock.
I've found the below snippet - can this be edited to say, for example, if the current stock is more than 1000 then hide the stock message?
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 );