{% if settings.related_products_count == "6" %} <style>.accentCollection:after{height: 38%;} </style> {% endif%}
{%if settings.show_related_products %}
	{% assign countToDisplay = settings.related_products_number_of %}
  {%assign handle = product.handle%}
  {% assign counter = '' %}

  {%if product.collections.last and product.collections.last.handle != 'frontpage' %}

    {%assign getCollection = product.collections.last.handle%}

	

	{% assign count = 0 %}
    {%capture productString%}
		{%for product in collections[getCollection].products%}
		
          {%unless product.handle == handle %}
				{% assign count = count | plus: 1 %}
				
              		{{product.handle}}
          {%endunless%}
		{%endfor%}
	{%endcapture%}
    {%if countToDisplay < 4%}
      {%assign needsExtra = true%}
    {%endif%}
  {%else%}
    {%assign getCollection = "all"%}
  {%endif%}
  {%if shop.products_count > 1 and product.collections.last.handle %}
	
	{%if settings.related_products_tyle == 'slider' %}
      <div class="relatedWrapper related_slider no_animation_effect">
        <div style="animation-duration: {{ settings.product_related_bottom_animation_duration }};" data-animation_name="{{ settings.product_related_bottom_animation_name }}" data-animation_delay="{{ settings.product_related_bottom_animation_delay }}" class="sectionWrap relatedItems featuredSliderWrap slickSlider price_color_variations {% if settings.product_related_bottom_animation_name != 'noeffect' %}scroll_animation{% endif %}">
          <h{{settings.related_products_heading_tag}} class="top-heading-wrap">{{ settings.related_products_heading }}</h{{settings.related_products_heading_tag}}>
          <div class="related_wrap_contene {%if settings.related_product_full_width == false %}grid{% endif %}">
            {% assign countToDisplay = settings.related_products_number_of %}

            <ul class="productListing flexWrap featured_product_slider_row_mob_{{ settings.related_products_count_mob }}"  data-full="{{settings.related_products_count}}"  data-tab="2" data-mob="{{ settings.related_products_count_mob}}" data-auto="false" data-timeout="" >
              {% for product in collections[getCollection].products%}
                {%if product.handle != handle and counter.size < countToDisplay %}
                  {%unless  product.handle == 'gift-card' %}
                    {% capture temp %}{{ counter }}*{% endcapture %}
                    {% assign counter = temp %}
                    {%include 'product-thumb-slider' with show_collection_in_link: settings.collection_seo_link %}
                  {%endunless%}
                {%endif%}
              {%endfor%}
              {%if needsExtra == true%}
                {% for product in collections.all.products%}
                  {%if product.handle != handle and counter.size < countToDisplay %}
                    {%unless productString contains  product.handle or product.handle == 'gift-card'%}
                      {% capture temp %}{{ counter }}*{% endcapture %}
                      {% assign counter = temp %}
                      {%include 'product-thumb-slider' with show_collection_in_link: settings.collection_seo_link %}
                    {%endunless%}
                  {%endif%}
                {%endfor%}
              {%endif%}  
            </ul>
            {%if counter.size > 3 or 1%}
              <span class="paraTwo control  prev">
                {%include 'svg-definitions' with 'arrow-new-left'%}
              </span>
              <span class="paraTwo control next">
                {%include 'svg-definitions' with 'arrow-new-right'%}
              </span>
            {%endif%}
          </div>

        </div>

      </div>
	{% else %}
		<div  id="relatedWrapperWrap" class="relatedWrapper related_grid hasGrid fxInElement sectionWrap BlockTitleContain no_animation_effect">
          <div style="animation-duration: {{ settings.product_related_bottom_animation_duration }};" data-animation_name="{{ settings.product_related_bottom_animation_name }}" data-animation_delay="{{ settings.product_related_bottom_animation_delay }}" class="{% if settings.product_related_bottom_animation_name != 'noeffect' %}scroll_animation{% endif %}">
            <div class="fxInElement easeIn">
              <div class="blockTitle flexGrid">
                <h{{settings.related_products_heading_tag}} class="top-heading-wrap">{{ settings.related_products_heading }}</h{{settings.related_products_heading_tag}}>
               
              </div>
            </div>
          

          <div class="fxInElement easeIn {%if settings.related_product_full_width == false %}grid{% endif %} grid_products">
            <ul class="productListing flexGrid gridJustify centerColumns product_per_line_{{ settings.related_products_count_mob}}">
              {% assign counter = 0 %}

              {%for product in collections[getCollection].products %}


                  {%if product.handle != handle and counter < countToDisplay %}
                  {%assign rows = 'thirds' %}
              	  {% if settings.related_products_count == '4' %}
              		{%assign rows = 'quarters' %}
              	  {% endif %}
              	  {% if settings.related_products_count == '6' %}
              		{%assign rows = 'sixth' %}
              	  {% endif %}
              	  {% if settings.related_products_count == '5' %}
              		{%assign rows = 'fifth' %}
              	  {% endif %}
              	  {% if settings.related_products_count == '7' %}
              		{%assign rows = 'grid-one-seven' %}
              	  {% endif %}
              	  {% if settings.related_products_count == '8' %}
              		{%assign rows = 'grid-one-eight' %}
              	  {% endif %}

            		{%include 'product-thumb' with rows show_collection_in_link: settings.collection_seo_link %}
                  {% assign counter = counter | plus: 1 %}
                {%endif%}

              {%endfor%}
            </ul>
          </div>
          {%if section.settings.btn_text != blank%}
              <a href="{{section.settings.btn_link}}" class="button btn_feature_item">{{section.settings.btn_text}}</a>
          {%endif%}
          </div>
        </div>
	{%endif%}
  {%endif%}
{%endif%}