将产品变量Shopify传递给snippet

将产品变量Shopify传递给snippet,shopify,product,render,code-snippets,assign,Shopify,Product,Render,Code Snippets,Assign,设置 我有一个首秀主题的Shopify商店 在主题的product card grid.liquid文件中,我调整/添加了以下代码,以便在集合网格中为每个产品卡添加额外的行 <div class="h4 grid-view-item__title product-card__title" aria-hidden="true">{{ product.title }}</div> {% include 'product-price'

设置

我有一个首秀主题的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 -%} 
然后尝试在
产品卡网格.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 %}  

{%- render 'own-collection-grid-spreadpayment' -%}        
但是,每种产品的额外生产线并没有显示出来

要么我做错了上面的操作,要么它与
产品
变量本身的特殊性有关


问题

我怎么,

  • product
    变量正确地传递给代码段,然后
  • 如何使用
    product
    变量正确呈现代码段

  • 您的代码有我以前从未见过的东西,它是
    incl.BTW

    不管怎样,这是

    将变量赋值为
    =
    而不是
    , 您正在将
    字符串
    传递给
    my_变量
    ,而不是
    对象
    ,当然它不会保存产品数据

    {% assign my_variable = product %}
    
    {% render 'own-collection-grid-spreadpayment' with my_variable %}
    

    own collection grid spreadpayment.liquid

    {% assign product = own-collection-grid-spreadpayment %}
    {%- 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 -%}   
    
    {%assign product=own collection grid spreadpayment%}
    {-如果product.price>10000且product.price<25000-%}
    renteloos的3x{{product.price |除以:3 | money(不带尾随的(零)}
    {%-elsif product.price>25000-%}
    gespreid vanaf的{product.price |倍:0.03287 | money |无_training_zero}}p/m
    {%-endif-%}
    
    {% assign my_variable = product %}
    
    {% render 'own-collection-grid-spreadpayment' with my_variable %}
    
    {% render 'own-collection-grid-spreadpayment' with product, a: a, b: b %}
    
    {% assign product = own-collection-grid-spreadpayment %}
    {%- 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 -%}