Hide inventory message on product page based on available stock quantity

Question

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

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/hide-inventory-message-on-product-page-based-on-available-stock-quantity/">

Hide inventory message on product page based on available stock quantity</a>
0
Lyall 5 months 0 Answers 88 views 0

Leave an answer