Product Option Names and Values

New Member
4 0 0

Currently using Icon theme from weareunderground.

 

What I would like to do is show my product options as:

variant.title: variant.option1

variant.title: variant.option2

variant.title: variant.option3

but only if the product only has a single default option value, if it has multiple options for a variant than I want to have it show as a dropdown selector.

 

Can someone please help me with this. i know i have the code for the first option if only 1 variant with default but not for the second or third variants options.

 

attached is my product.form.liquid that has the product options. 

I have used metafields but when I add new products to my store and if i forget to update the metafields the options done show.  unless there is a way to do so that i am unaware of please help me!!!

 

Any help would be great.

 

    {% if product.options.size > 1 %}
     <div class="select" {% if product.variants.size == 1 or section.settings.product_variants == 'swatches' %}style="display: none;"{% endif %}>
       <select id="product-select-{{ product.id }}" name='id'>
         {% for variant in product.variants %}
           <option value="{{ variant.id }}" {% if variant == current_variant %}selected="selected"{% endif %}>
             {{ variant.title }} - {{ variant.price | money }}
           </option>
         {% endfor %}
       </select>
     </div>
      {% if section.settings.product_variants == 'swatches' %}
        {% for option in product.options_with_values %}
          {% include "swatch" %}
        {% endfor %}
      {% endif %}
    {% elsif product.options.size == 1 and product.variants.size > 1 %}
    <div class="select" {% if product.variants.size == 1 or section.settings.product_variants == 'swatches' %}style="display: none;"{% endif %}>
       <label>{{ product.options[0] }}</label>
       <select id="product-select-{{ product.id }}" name='id'>
         {% for variant in product.variants %}
           <option data-sku="{{ variant.sku }}" value="{{ variant.id }}" {% if variant == current_variant %}selected="selected"{% endif %}>
             {{ variant.title }} - {{ variant.price | money }}
           </option>
         {% endfor %}
       </select>
     </div>
     {% if section.settings.product_variants == 'swatches' %}
       {% for option in product.options_with_values %}
         {% include "swatch" %}
       {% endfor %}
     {% endif %}
    {% else %}
     <div class="what-is-it">
       {% if product.options.first != 'Title' %}
         <label>{{ product.options.first }}:</label>
         {% for variant in product.variants %}
           <span class="it-is">{{ variant.option1 | escape }}</span>
         {% endfor %}
       {% endif %}
     </div>

 

 

0 Likes
Highlighted
Shopify Expert
278 14 54

Hi!

Please provide your store Url!

Regards

Sudipta 
MS Web Designer | Task4Store
20,000+ Tasks Completed | 1000+ Happy Clients

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution

0 Likes