【发布时间】:2021-03-25 10:26:37
【问题描述】:
设置
我有一个以 Debut 为主题的 Shopify 商店。
在主题的product-card-grid.liquid 文件中,我已经调整/添加了以下代码以在集合网格中为每个产品卡添加额外的行,
<div class="h4 grid-view-item__title product-card__title" aria-hidden="true">{{ product.title }}</div>
{% include 'product-price' incl. BTW, variant: product.selected_or_first_available_variant, product: product, show_vendor: show_vendor %}
{%- if product.price > 10000 and product.price < 25000 -%}
<font size = "2">Of renteloos 3x <strong>{{ product.price | divided_by:3 | money_without_trailing_zeros }}</strong></font>
{%- elsif product.price > 25000 -%}
<font size = "2">Of gespreid vanaf <strong>{{ product.price | times: 0.03287 | money_without_trailing_zeros }}</strong> p/m</font>
{%- endif -%}
效果很好。
问题
如果我创建看起来像这样的 sn-p own-collection-grid-spreadpayment.liquid,
{%- if product.price > 10000 and product.price < 25000 -%}
<font size = "2">Of renteloos 3x <strong>{{ product.price | divided_by:3 | money_without_trailing_zeros }}</strong></font>
{%- elsif product.price > 25000 -%}
<font size = "2">Of gespreid vanaf <strong>{{ product.price | times: 0.03287 | money_without_trailing_zeros }}</strong> p/m</font>
{%- endif -%}
然后尝试像这样渲染product-card-grid.liquid中的sn-p,
<div class="h4 grid-view-item__title product-card__title" aria-hidden="true">{{ product.title }}</div>
{% include 'product-price' incl. BTW, variant: product.selected_or_first_available_variant, product: product, show_vendor: show_vendor %}
{%- render 'own-collection-grid-spreadpayment' -%}
每个产品的额外行不显示。
尝试
我知道变量应该像这样传递给 sn-p,
{%- assign my_variable:'product' -%}
{%- render 'own-collection-grid-spreadpayment', my_variable:my_variable -%}
但仍然没有显示每个产品的额外行。
要么我做错了,要么与 product 变量本身的特殊性有关。
问题
我该怎么做,
- 将
product变量正确传递给sn-p,并且; - 如何正确渲染带有
product变量的sn-p?
【问题讨论】:
标签: shopify product render code-snippets assign