I have built this code snippet for my shopify store to display more information in the dropdown field. With the change, the status is now also displayed next to the size selection. Available or Sold Out. Unfortunately I can't get it solved that if the stock quantity on a variant is less than 2, that the system then displays the text. Only 1 available.
<select id="product-select-{{ product.id }}" name="id" class="main_select">
{% for variant in product.variants %}
{% if variant.available %}
<option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} value="{{ variant.id }}">{{ variant.title }} <span>Verfügbar: {{ variant.inventory_quantity}}</span></option>
{% else %}
<option disabled="disabled">
{{ variant.title }} - {{'products.product.sold_out' | t }}
</option>
{% endif %}
{% endfor %}
</select>
<span>Verfügbar: {{ variant.inventory_quantity}}
, but than it shows the quantity for all available variants, but i would like to show it only to those products, where the quantity is less than two - p_e_88