I am using the "Simple" theme. I have many products with options that contain only 1 variant, and I want to hide these drop-downs. How can I do it? As I saw, there are solutions for some other themes, but I couldn't found a solution for the "Simple" theme.
Please, Help. Thanks, Liad,
Solved! Go to the solution
Hello,
You can use condition in your theme code. like this one
{% if product.options.size > 1 %}
This is an accepted solution.
You can use the bellow code on the product-template.liquid (paste at the end of the file)
{%- if product.variants.size == 1 -%} <style> .selector-wrapper{ display: none; } </style> {%- endif -%}
Hi again. I did a thumb up :)
But actually, there is a problem. It works fine when the product has ONE option with ONE variant.
But it does not work when there are many options. I will add some images to help you understand what I am talking about.
As you can see, there are three options here, and the first one has only one variant. This is what I want to hide.
Thanks again, Liad.
Alright, in that case, you need to replace previous code with below snippet
<style> {% for option in product.options %} {% if product.options_by_name[option].values.size == 1 %} #ProductSelect-product-template-option-{{ forloop.index0 }}, [for="ProductSelect-product-template-option-{{ forloop.index0 }}"]{ display: none !important; } .selector-wrapper:nth-of-type({{ forloop.index }}){ padding: 0 !important; } {% endif %} {% endfor %} </style>
Hi again and really, thank you for your fast replies!
I am sorry to bother you, but there is one last issue.
Your last solution solved the previous issue where there were many options, but it created a small problem when there is one option (the drop-down disappears, but his title stays). I will add 2 photos, one that shows the problem, and that shows that the previous issue has been solved.
I really appreciate your help man!
Liad.
User | Count |
---|---|
542 | |
209 | |
126 | |
79 | |
44 |