Sold out status variants

fe1tclassic
New Member
1 0 0

Hy guys. I hope you can help me . Product sizes grid look like this. If size variant sold out - name + Sold out status.

 Без имени.png

I was able to implement in this way -

<select class="single-option-selector single-option-selector-{{ section.id }} product-form__input notranslate"
id="SingleOptionSelector-{{ forloop.index0 }}"
data-name="{{ option.name }}"
data-index="option{{ forloop.index }}">
{% for value in option.values %}

{% if product.options_with_values.size == 1 %}
{% assign show_sold_out = 1 %}
{% else %}
{% assign show_sold_out = 0 %}
{% endif %}


{% assign sold_out = false %}
{% if show_sold_out %}
{% for variant in product.variants %}
{% if variant.option1 == value %}
{% unless variant.available %}
{% assign sold_out = true %}
{% endunless %}
{% endif %}
{% endfor %}
{% endif %}
<option {% if option.selected_value == value %}selected{% endif %} value="{{ value }}">
{{ value }}{% if sold_out %} - {{ 'products.product.sold_out' | t }}{% endif %}
</option>
{% endfor %}
</select>

But, if product have two sized grid , sold out status work only in first size options. 
Без имени1.pngБез имени2.png
What i am need change in code to make it work with two sized grid? Do not show sold out status in the first and show sold out status in the second sized grid. 

Replies 0 (0)