如何通过tag-shopify显示相关产品
我的产品页面上有一个“相关产品”部分,以“Vatage”为主题。现在,它显示了通过“集合”关联的产品。是否可以显示具有相同标签的相关产品? 我尝试了其他代码,但失败了。。 请有人帮帮我 这是我的相关产品。液体代码 谢谢如何通过tag-shopify显示相关产品,shopify,Shopify,我的产品页面上有一个“相关产品”部分,以“Vatage”为主题。现在,它显示了通过“集合”关联的产品。是否可以显示具有相同标签的相关产品? 我尝试了其他代码,但失败了。。 请有人帮帮我 这是我的相关产品。液体代码 谢谢 {% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %} {% if collection == nul
{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}
{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
{% assign found_a_collection = false %}
{% for c in product.collections %}
{% if found_a_collection == false and c.handle != 'frontpage' and c.handle != 'all' and c.all_products_count > 1 %}
{% assign found_a_collection = true %}
{% assign collection = c %}
{% endif %}
{% endfor %}
{% endif %}
<div class="desktop-12 mobile-3">
<h4 class="section-title">{{ 'products.product.related_products' | t }}</h4>
<div id="product-loop">
{% assign current_product_found = false %}
{% for prod in collection.products limit: 7 %}
{% if prod.title == product.title %}
{% assign current_product_found = true %}
{% else %}
{% unless current_product_found == false and forloop.last %}
<div class="product-index desktop-2 tablet-2 mobile-half" id="prod-{{ product.id }}" data-alpha="{{ prod.title }}" data-price="{{ prod.price }}">
<a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}">
<img src="{{ prod.featured_image | product_img_url: 'large' }}" alt="{{ product.title | escape }}" />
</a>
<div class="product-info">
<div class="product-info-inner">
<a href="{{ prod.url | within: collection }}">
<h3>{{ prod.title }}</h3>
</a>
<div class="price">
{% if product.price < prod.compare_at_price %}
<div class="onsale">{{ prod.price | money }}</div>
<div class="was">{{ prod.compare_at_price | money }}</div>
{% else %}
<div class="prod-price">{% if prod.price_varies %} {{ 'products.general.from' | t }} {{ prod.price_min | money }} - {{ prod.price_max | money }} {% else %}{{ prod.price | money }}{% endif %}</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endunless %}
{% endif %}
{% endfor %}
</div>
</div>
{u相关产品的%capture number}{u相关产品的%capture number}{u展示}加上:1}{%endcapture%}
{%if collection==null或collection.handle='frontpage'或collection.handle='all%}
{%assign found_a_集合=false%}
{product.collections%中c的%s}
{%if find_a_collection==false和c.handle!='frontpage'和c.handle!='all'和c.all_产品计数>1%}
{%assign found_a_集合=true%}
{%assign集合=c%}
{%endif%}
{%endfor%}
{%endif%}
{{'products.product.related|u products'{t}
{%assign current_product_found=false%}
{集合中产品的百分比。产品限制:7%}
{%if prod.title==product.title%}
{%assign current_product_found=true%}
{%else%}
{%除非找到当前的_产品==false和forloop.last%}
{如果product.price
{%assign image_size='compact%}
{%assign heading='其他精细产品'%}
{%if product.tags.size>0%}
{{heading}}
.相关产品{列表样式类型:无}
{%case image_size%}
{%when'小'%}
.相关产品*{字体大小:12px;文本对齐:居中;填充:0}
.相关产品h4{边框:无;边距:10px 0;线高:1.3}
.相关产品部门图片{高度:100px}
.相关产品li{浮动:左;宽度:120px;高度:160px;右边距:20px}
{%when'compact%}
.相关产品*{字体大小:13px;文本对齐:居中;填充:0}
.相关产品h4{边框:无;边距:5px 0 0;线条高度:1.5}
.相关产品部门图片{高度:160px}
.相关产品li{浮动:左;宽度:180px;高度:220px;右边距:25px}
{%when'medium%}
.相关产品*{字体大小:14px;文本对齐:居中;填充:0}
.相关产品h4{边框:无;边距:10px 0;线高:1.8}
.相关产品部门图片{高度:240px}
.相关产品li{浮动:左;宽度:260px;高度:300px;右边距:25px}
{%endcase%}
.相关产品{溢出:隐藏}
.相关产品span.money{font size:0.8em}
.相关产品li:最后一个子项{页边距右侧:0}
!window.jQuery和document.write(“”)
{{'api.jquery.js'| shopify_asset_url | script_tag}
//
{%endif%}
参考:
或者使用商店中的付费应用。可能重复感谢您的评论。我已经尝试过使用该代码,但它不起作用。我不知道为什么,有什么问题吗。这就是为什么我在这里问你。谢谢-
<!-- Solution brought to you by Caroline Schnapp -->
<!-- See this: http://wiki.shopify.com/Related_Products -->
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% if product.tags.size > 0 %}
<h3>{{ heading }}</h3>
<ul class="related-products"></ul>
<style type="text/css">
.related-products { list-style-type:none }
{% case image_size %}
{% when 'small' %}
.related-products * { font-size:12px; text-align:center; padding:0 }
.related-products h4 { border:none; margin:10px 0 0 0; line-height:1.3 }
.related-products div.image { height:100px }
.related-products li { float:left; width:120px; height:160px; margin-right:20px }
{% when 'compact' %}
.related-products * { font-size:13px; text-align:center; padding:0 }
.related-products h4 { border:none; margin:5px 0 0 0; line-height:1.5 }
.related-products div.image { height:160px }
.related-products li { float:left; width:180px; height:220px; margin-right:25px }
{% when 'medium' %}
.related-products * { font-size:14px; text-align:center; padding:0 }
.related-products h4 { border:none; margin:10px 0 0 0; line-height:1.8 }
.related-products div.image { height:240px }
.related-products li { float:left; width:260px; height:300px; margin-right:25px }
{% endcase %}
.related-products { overflow:hidden }
.related-products span.money { font-size:0.8em }
.related-products li:last-child { margin-right:0 }
</style>
<script>!window.jQuery && document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"><\/script>')</script>
{{ 'api.jquery.js' | shopify_asset_url | script_tag }}
<script type="text/javascript" charset="utf-8">
//<![CDATA[
var recommendations = [];
{% for tag in product.tags %}
recommendations.push('{{ tag | handle }}');
{% endfor %}
if (recommendations.length) {
var list = jQuery('ul.related-products');
for (var i=0; i<recommendations.length; i++) {
jQuery.getJSON(recommendations[i] + '.js', function(product) {
list.append('<li><div class="image"><a href="' + product.url +'"><img src="' + product.images[0].replace(/(\.jpg|\.png|\.jpeg|\.gif)/, '_{{ image_size }}$1') + '" /></a></div><h4><a href="' + product.url + '">' + product.title + '</a></h4><span class="money">' + Shopify.formatMoney(product.price, "{{ shop.money_format }}") + '</span></li>');
});
}
}
//]]>
</script>
{% endif %}