How to get woocommerce inventory status [closed]

In a woocommerce theme, Im trying to show a warning when product is out of stock. Something like this:

<?php if ('this_product_is_out_of_stock'): ?>
    <p>This product is out of stock. It can be purchased by custom made order.</p>
<?php endif; ?>

Is there a function to say ‘this_product_is_out_of_stock’ or some other way to achieve it?

I was searching woocommerce api docs unsuccesfully: https://docs.woocommerce.com/wc-apidocs/

Thank you in advance.

1
1

Try something like this

    global $product;
    if ( ! $product->managing_stock() && ! $product->is_in_stock() )
    echo '<p>This product is out of stock. It can be purchased by custom made order.</p>';

Leave a Comment