NO BUG: Conditions to show/hide element based on Woo Stock in variable products isn't working

Hello Bricks team! :blush:

I am trying to show / hide an element in the page product based on the stock status of a variable product in WooCommerce.

Following this thread, I am building a condition like this:

But it is not working.

I assume it is because the product is a variable product and the stock management is not done at the product level, but at the variations level. I would like to show a notice on the page when all the variations have stock = 0 / out of stock.

I have tried different approaches on the condition, like {woo_product_stock} < 1, or contains out / out of stock / Out of stock, or {woo_product_stock} = 0, etc. Even tried with {woo_product_stock_status}. Nothing works!

So I think the issue is related to the way the stock is managed when it is a variable product and each variation has specific stock values.

What can I do in this scenario?

Thank you very much!

Hi Isaura,
Thanks so much for your report!

{woo_product_stock_status} should work (it does for me) and return either ā€œinstockā€ or ā€œoutofstockā€, provided that ā€œManage stockā€ is checked for each variation (variation level).

If all variations have 0 stock, ā€œoutofstockā€ should be output. The condition would be:

Best regards,
timmse

Hi @timmse,

Oh, ok, so it is not ā€œout of stockā€, but ā€œoutofstockā€ as a word. I assume thatā€™s why it didnā€™t work with Contains > out.

Thank you very much!