I’ve been trying to implement size variants in my Shopify theme, but I’m encountering issues. Currently, when clicking on a size variant, it opens the product page instead of selecting the size. What I actually need is for clicking on a size variant to select it, and then allow customers to add the item to their cart by pressing a button, which should also open the quick cart. If anyone has a solution to this problem, please help me out.
{% assign variantCount = product.variants | size %}
{% if product.available and variantCount > 0 %}
{% if downcased_option contains ‘size’ %}
{% assign option_index = forloop.index0 %}
{% assign option_count = 0 %}
{% assign values = ‘’ %}
{% for variant in product.variants %}
{% assign value = variant.options[option_index] %}
{% unless values contains value %}
{% if option_count > 0 %}
{% assign values = values | join: ‘|’ | append: ‘|’ %}
{% endif %}
{% assign values = values | append: value %}
{% assign values = values | split: ‘|’ | sort %}
{% assign option_count = values | size %}
{% if variant.available %}
{% if option_count <= 6 %}
{% endunless %}
{% endfor %}
{% if values.size >= 6 %}
{% endif %}{% endif %}
{% endfor %}