Hi everyone,
I’m trying to hide product option if there is only one variant.
I tried with this code :
{% if product.variants.size == 1 %}
But it doesn’t work when I have two product options. The result of :
{{ product.variants.size }}
is always the size of the second product options.
For example if my product has:
- Color : Red
- Size : S - M - L
{{ product.variants.size }} for Color display 3 (instead of 1)
{{ product.variants.size }} for Size display 3
I use Venture theme and my full code is:
{% for option in product.options_with_values %}
--{{product.variants.size}}--
<div class="selector-wrapper js product-form__item">
<label {% if option.name == 'default' %}class="label--hidden" {% endif %}for="SingleOptionSelector-{{ section.id }}-{{ forloop.index0 }}">{{ option.name }}</label>
<select class="single-option-selector single-option-selector-{{ section.id }} product-form__input"
id="SingleOptionSelector-{{ forloop.index0 }}"
data-name="{{ option.name }}"
data-index="option{{ forloop.index }}">
{% for value in option.values %}
<option value="{{ value | escape }}"{% if option.selected_value == value %} selected="selected"{% endif %}>{{ value }}</option>
{% endfor %}
</select>
</div>
{% endfor %}
Any idea? Thx