Use an IF – Else condition in Twig to show one part of the HTML when a condition is true, and another part when it is false. You can add this code from Twig Code Examples > IF – Else in the widget creator. To learn how, see Showing twig code examples.
{% if product_stock == 0 %}
{% else %}
{% endif %}
In this example, product_stock is the name of an attribute. When its value is 0, the first part is shown. For any other value, the part after {% else %} is shown.
You can use these comparisons in the condition: == (equal), != (not equal), <, >, <= and >=. To check more than one condition, join them with and or or.
Another example, with a Radio Boolean attribute: