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

Comments

2 comments

  • 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
  • Avatar
    Charles Lu

    Hello!

    I was trying to solve the same issue for a client and was able to come up with a solution. I created a guide here!

    The implementation has been live on the site for around 1 week and so far no hiccups!

    If you need help with implementation feel free to reach out via email! pofobuilds@gmail.com

     

    Best,

    Charlie

    0
    Comment actions Permalink

Please sign in to leave a comment.