{% assign product = all_products[settings[subproducts]] %}
{% assign on_sale = false %}
{% if product.compare_at_price > product.price %}
  {% assign on_sale = true %}
{% endif %}
{% assign sold_out = true %}
{% if product.available %}
  {% assign sold_out = false %}
{% endif %}

{%assign thumbSize = product-thumb%}
{% case thumbSize %}
  {% when 'full' %}
    {%assign size = "fullSpan"%}
    {%assign img_size = "master"%}
  {% when 'half' %}
    {%assign size = "half"%}
    {%assign img_size = "1024x1024"%}
  {% when 'thirds' %}
    {%assign size = "oneThird"%}
    {%assign img_size = "1024x1024"%}

  {% when 'quarters' %}
    {%assign size = "oneQuarter"%}
    {%assign img_size = "grande"%}

  {% when 'mixGrid' %}
    {%capture size%}
      {%cycle 'half','half','oneThird','oneThird','oneThird'%}
    {%endcapture%}
    {%assign img_size = "1024x1024"%}
  {% when 'mixGridTwo' %}
    {%capture size%}
      {%cycle 'oneThird','oneThird','oneThird', 'half','half'%}
    {%endcapture%}
     {%assign img_size = "1024x1024"%}
{%endcase%}
{% if template == 'collection' %}
	{%assign size = settings.collection_product_perline %}
{% endif %}

<div class="prodThumb flexItem">
  <a href="{{ product.url | within: collection }}">
    {% if on_sale %}
      <span class="tag">{{ 'products.product.on_sale' | t}}</span>
    {%endif%}
    {% if sold_out %}
      <span class="tag">{{ 'products.product.sold_out' | t}}</span>
    {% endif %}
      
      <div class="imgWrap gridJustify centerColumns">
        <img src="{{product.images.first | img_url:'250x'}}" alt="{{product.images.first.alt}}">
      </div>

    <div class="title gridJustify megamenu_product_title">
      <span>{{product.title}}{{img_url}}</span>
      <span>
        {% if on_sale %}
          {% if product.price_varies %}
            {% assign price = product.price | money %}
              {{ 'products.general.from_text_html' | t: price: price }}
          {% else %}
            <strike>{{ product.compare_at_price | money }}</strike> {{ product.price | money }}
          {% endif %}
        {% else %}
          {% if product.price_varies %}
            {% assign price = product.price | money %}
            {{ 'products.general.from_text_html' | t: price: price }}
          {% else %}
            {{ product.price | money }}
          {% endif %}
        {% endif %}
      </span>
    </div>
  </a>
</div>