kieran-mallon-shopify of Archived Theme Support
8/20/2018 - 2:47 PM

Available in X styles

This will allow you to display a message stating the amount of variant options on the product card.

This has been taken from Kevin Schaekens forum post a slightly tweeked.

http://screenshot.click/20_-46-b9hzc-_5mmnd.jpg

Add the following code below wherever you want within the product card. I added it just after the price.

If you want to only show this code for products with 2 or more options then replace line 20 with the following: {% unless option == "Title" %}{% if current_options.size > 1 %}Available in {{current_options.size}} styles{% endif %}{% unless forloop.last == true %},{% endunless %}{% endunless %}

     {%comment%}Loop through all the options and find out how many unique options within the variants{% endcomment %}
      {% assign option_index = 0 %}
      {% for option in product.options %}
        {% capture downcased_option %}{{ option | downcase }}{% endcapture %}
        {% assign option_index = forloop.index0 %}
        {% assign how_many_options = 0 %}
        {% assign current_options = '' %}
        {% for variant in product.variants %}
          {% assign current_option = variant.options[option_index] %}
          {% unless current_options contains current_option %}
            {% if how_many_options > 0 %}
              {% assign current_options = current_options | join: '|' | append: '|' %}
            {% endif %}
            {% assign current_options = current_options | append: current_option %}
            {% assign current_options = current_options | split: '|' | sort %}
            {% assign how_many_options = current_options | size %}
          {% endunless %}
        {% endfor %}
        {%comment%}Output the amount of options for each option. Add an 's' if there is more than one available{% endcomment %}
        {% unless option == "Title" %}Available in {{current_options.size}} style{% if current_options.size > 1 %}s{% endif %}{% unless forloop.last == true %},{% endunless %}{% endunless %}
      {% endfor %}