Option is not showing if I only have one variant

New Member
2 0 0

Hi there,

 

I am new to Shopify. I have added variants to my product but once I remove a bunch of them and only leave one, it stops showing the option on the product page. I want to only have one option that says "Custom" and which shows on the product page. Please help

 

This is my product-form.liquid code, since my product.liquid only has two lines

 

{% assign call_to_action = 'products.product.add_to_cart' | t %}

{% unless current_variant.available %}
{% assign call_to_action = 'products.product.sold_out' | t %}
{% endunless %}

{% form 'product', product, id: "AddToCartForm", class: "product_form", data-product-form:product_form_config %}
{% include 'product-customizer' %}


{%- if settings.show_multiple_currencies -%}
{% assign price = current_variant.price | money_with_currency %}
{% assign compare_price = current_variant.compare_at_price | money_with_currency %}
{%- else -%}
{% assign price = current_variant.price | money %}
{% assign compare_price = current_variant.compare_at_price | money %}
{%- endif -%}
<p id="product-price">
<span class="product-price" itemprop="price">
<span class="money">{{ price }}</span>
</span>
{% if current_variant.compare_at_price > current_variant.price %}
<span class="was">
<span class="money">{{ compare_price }}</span>
</span>
{% endif %}
</p><div class="clear"></div>

{% 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' with option %}
{% endfor %}
{% endif %}
{% elsif product.variants.size == 1 %}
<select id="product-select-{{ product.id }}" name="id" {% if product.variants.size == 1 or section.settings.product_variants == 'swatches' %}style="display: none;"{% endif %}>
{% for variant in product.variants %}
<option value="{{ variant.id }}" {% if variant == current_variant %}selected="selected"{% endif %}>
{{ variant.title }} - {{ variant.price | money }}
</option>
{% endfor %}
</select>
{% 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>
<div class="product-variants"></div><!-- product variants -->
<input type="hidden" id="{{ variant.id }}" name="id" data-sku="{{ variant.sku }}" value="{{ product.variants[0].id }}" />
{% endif %}

{% if section.settings.show_sku %}
<div class="clear"></div>
<div class="sku">
<label style="line-height: 1.6em; display: inline-block;">{{ 'customer.order.details.sku' | t }}:</label> <span class="variant_sku">{{ current_variant.sku }}</span>
</div><div class="clear"></div>
{% endif %}

<div id="infiniteoptions-container"></div>

<div class="product-add">
{% if section.settings.show_quantity %}
<label for="quantity">{{ 'products.product.quantity' | t }}</label>
<input min="1" type="number" id="quantity" name="quantity" value="1" />
{% endif %}
<input type="submit" name="button" class="add clearfix AddtoCart{% if section.settings.show_payment_button %} secondary-button{% endif %}" value="{{ call_to_action }}" {% unless current_variant.available %}disabled{% endunless %} />
{% if section.settings.show_payment_button %}
{% if product.metafields.product_customizer == empty %}{{ form | payment_button }}{% endif %}
{% endif %}
</div>
{% endform %}

0 Likes

Hello 

 

Want to modify or custom changes on store hire us.
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Content Writer | Digital Marketing | SEO Expert | Site Optimization | Web Design | Web Development
0 Likes
New Member
2 0 0
Parker
0 Likes