how to hide single variant label/button when only has one variant for a product? (Dawn Theme)

@i_hussain Please try hiding the variants using below steps instead of the one shared in previous comment. Let me know whether it is helpful for you.

  1. Go to “Online stores” → “Themes”.
  2. Click action button from the current theme and select “Edit code”.
  3. Search for “product-variant-picker.liquid” file.
  4. Keep the code “{% assign variant_count = option.values | size %}” added next to the line {%- for option in product.options_with_values -%}
    5**.** Remove the codes {% if variant_count > 1 %} and {%- endif -%} added previously.
  5. Then, find the “product-form__input–pill” and “product-form__input–dropdown” class names and paste the below code next to the both classes like in the attached screenshot.
{% if variant_count <= 1 %} hide_single_variant{% endif %}

  1. Search “base.css” file and paste below code at the bottom of the file.
.hide_single_variant {
    display: none !important;
}

Now, it will works fine as we expected.

Please provide your support by click “Like” and “Accepted” if our solution works for you. Thanks for your support.

1 Like