← back to Dw Theme Hamburger

snippets/product-options-dropdown.liquid

62 lines

{% assign has_tag = "no" %}

{% for tag in product.tags %}
	{% if tag == "display_variant" %}
		{% assign has_tag = "yes" %}
		{% break %}
	{% endif %}
{% endfor %}


{% unless product.options.size == 1 and product.variants[0].title == 'Default Title' %}
  {% for option in product.options_with_values %}
    {% assign option_index = forloop.index0 %}
    {%- capture option_id -%}
      single-option-{{ form_id }}-{{ option_index }}
    {%- endcapture -%}

    <label
      class="product-option-column-1 product-option-row-{{ forloop.index }} selected-text"
      for="{{ option_id }}"
      data-select-text>
      <strong>{{ option.name }}:</strong>
    </label>
  

	
	<div class="last_variant product-option-row-{{ forloop.index }}" {% if has_tag == "yes" %} style="display:none !important;" {% endif %}> 
      {% for value in option.values %}
        {% if forloop.last == true %}
      		{{ value }}
        {% endif %}
      {% endfor %}
    </div>
	

    <select
      class="single-option-selector select product-option-row-{{ forloop.index }}"
      id="{{ option_id }}"
      data-option-select
      data-option-select="{{ form_id }}"
      data-option-index="{{ option_index }}" {% if has_tag == "yes" %} style="display:block !important;" {% endif %}>
      {% for value in option.values %}
        {% assign data-sku = blank %}
        {% for item in product.variants %}
            {% if item.title == value %}
              {% assign data-sku = item.sku %}
              {% break %}
            {% endif %}
        {% endfor %}
        <option data-vprice="{{product.variants[forloop.index0].price}}" data-vindex="{{forloop.index}}"
          value="{{ value | escape }}"
          {% if option.selected_value == value %}selected="selected"{% endif %} {% if data-sku != blank %}data-sku="{{data-sku}}" {% endif %}>
          {{ value }}
        </option>
      {% endfor %}
    </select>
	
  {% endfor %}
{% endunless %}

<input type="hidden" id="has_display_variant" value="{{ has_tag }}">