How to Set an auto select option in variants dropdown for product page in Parallax Theme

Comments

1 comment

  • Avatar
    Cakes by Sophie HK

    I found the location of the "select option" field under the  product-form.liquid, however, I don't know the correct syntax of adding additional option like "Choose your variant" in the dropdown. heres the code below.

        {% if product.options.size > 1 %}
          <div class="select">
          <select id="product-select-{{ product.id }}{{ product-form }}{{ section.id }}{{ block.id }}" name="id" class="multi_select">
        {% for v in product.variants %}
          <option {% if v == variant %}selected="selected"{% endif %} value="{{ v.id }}" data-sku="{{ v.sku }}">{{ v.title }}</option>
        {% endfor %}
          </select>
    </div>
       
        {% elsif product.options.size == 1 and product.variants.size > 1 or product.options.size == 1 and product.options[0] !=             "Title" %}
        <div class="select">
        <label>{{ product.options[0] }}</label>
        <select id="product-select-{{ product.id }}{{ product-form }}{{ section.id }}{{ block.id }}" name="id">
        {% for v in product.variants %}
        <option {% if v == variant %}selected="selected"{% endif %} value="{{ v.id }}" data-sku="{{ v.sku }}">{{ v.title }}</option>
        {% endfor %}
        </select>
    </div>

    {% else %}
        <input type="hidden" name="id" value="{{ variant.id }}" />
    {% endif %}

    0
    Comment actions Permalink

Please sign in to leave a comment.