Product Tags Referencing Issues With Product Title

Highlighted
New Member
2 0 0

Hi All,

 

I am having an issue with the Shopify product title not being referenced in product tags in loop. It works in some cases but do not works in all cases. What i am doing is very simple, a product title is added as a tag on any other product. Through iterating all collection products i am only checking if current product tag matches with any collection product if so then display all the product info of that linked product. Can anyone tell what is the issue. It probably looks like a shopify issue which is not comparing tag name with product title properly. Any help would be greatly appreciated.

 

{% if section.settings.show_cross_sell_prod %}
      {% if product.tags contains 'Tb Cross Sell' or product.tags contains 'tb cross sell' or product.tags contains 'TB CROSS SELL' %}
       <div class="tb-cross-sell">
         {% if section.settings.cross_sell_title != blank %}
         	 <h5>{{ section.settings.cross_sell_title }}</h5>
         {% endif %}
         
         <div class="tb-cs-slider">
          {% for tag in product.tags %}
              {% for product in collections.all.products %}
                  {% if tag contains product.title %} (This do not works in all cases)
                    {% if product.has_only_default_variant %}
                      <div class="tb-csell-wrap" data-csell-product="{{product.id}}">
                         <img src="{{ product | img_url }}"/>
                         <h4><a href="{{ product.url}}">{{ product.title }}</a></h4>
                         <strong>{{ product.price | money  }}
                          {% if product.compare_at_price_max > product.price %}
                              <span class="tb-l-through">{{ product.compare_at_price_max | money }}</span>
                          {% endif %}
                         </strong>
                        {% if product.available %}
                        	<a href="#" onclick="return false;" class="tb-var-add-cart" data-variant-id="{{ product.variants.first.id}}">Add</a>
                        {% else %}
                      	  <span class="tb-sold">Sold Out</span>
                        {% endif %}
                      </div> 
                    {% else %} 
         				 {% if product.variants.size > 1 %}
         				 	{% for variant in product.variants %}
                       			{% if variant.available %}
                                 <div class="tb-csell-wrap {{var_class}}" data-csell-product="{{product.id}}">
                                    <img src="{{ variant | img_url }}"/>
                                    <h4><a href="{{ product.url}}">{{ variant.title }}</a></h4>
                                    <strong>{{ variant.price | money  }}
                                     {% if variant.compare_at_price > variant.price %}
                                          <span class="tb-l-through">{{ variant.compare_at_price | money }}</span>
                                      {% endif %}
                                    </strong>
                                    {% if variant.inventory_quantity > 0 %}
                                       <a href="#" onclick="return false;" class="tb-var-add-cart" data-variant-id="{{variant.id}}">Add</a>
                                    {% else %}
                                       <span class="tb-sold">Sold Out</span>
                       	 			{% endif %}
                     	 		</div>
                      		   {% endif %}
                   			{% endfor %}
         				 {% endif %}
                    {% endif %}
                  {% endif %}
              {% endfor %}
          {% endfor %}
          </div>
       </div>
      {% endif %}
    {% endif %}

Kind Regards,

 

0 Likes