【发布时间】:2020-07-01 23:12:45
【问题描述】:
我想在我的 shopify 购物车页面上添加产品推荐。
我已添加:
{% section 'product-recommendations' %} 在cart.liquid 文件中。
此文件包括:
{%- if section.settings.show_product_recommendations -%}
{%- if recommendations.performed -%}
{%- if recommendations.products_count > 0 -%}
<div class="product-recommendations__inner">
{%- if section.settings.heading != blank -%}
<div class="section-header">
<h2>{{ section.settings.heading | escape }}</h2>
</div>
{%- endif -%}
<ul data-slides="8" id='product-slider' class="grid grid--uniform grid--view-items product-slider">
{%- for product in recommendations.products -%}
<li class="grid__item small--one-half medium-up--one-quarter">
{% include 'product-card-grid', max_height: 250, product: product, show_vendor: section.settings.show_vendor %}
</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}
{%- else -%}
<div class="page-width recommendations-container" data-base-url="{{ routes.product_recommendations_url }}" data-product-id="{{ product.id }}" data-section-id="{{ section.id }}" data-section-type="product-recommendations"></div>
{%- endif -%}
{%- endif -%}
它被插入到页面中(我可以看到容器),但除了容器边距/填充之外没有任何实际呈现。我怀疑是因为我不在产品页面上。
如何在购物车页面上进行这项工作?
【问题讨论】:
-
至少分享一下product-recommendations.liquid的代码,这样我们就可以看到什么都不显示的代码了。
-
@BilalAkbar 我已经分享了这个 - 它应该是标准的 Shopify 首次亮相主题代码。我还没有继续提供包含的“产品卡网格”的代码——这也应该是标准代码——我没想到会影响它,但如果需要可以提供。谢谢
标签: javascript shopify liquid