shopify的版块页如何调用商品图片、详情、价格?

How can I call product image, details, and price on the section page in Shopify?

{% for block in section.blocks %}
{% for image in product.images %} {{ image.src | product_img_url: 'grande' }} {% endfor %}
{{block.settings.product.title}}
{{all_products[product].price | money_without_trailing_zeros }}
{% endfor %}

{% schema %}
{
"name": "Demo",
"blocks": [
{
"type": "new-arrival",
"name": "New Arrival",
"settings": [
{
"type": "product",
 "id": "product",
"label": "Product"
}

]
 }
]
}
{% endschema %}

谁能告诉我如何在版块页面调用多个产品图片、产品详情和产品价格? 这里有一些我试过但不正确的代码。

当使用输入类型 product 到 Shopify 模式中时,您需要使用 all_products 对象来获取所选产品的详细信息,您需要获取详细信息并将其分配给变量,像这个。

{% assign product = all_products[block.settings.product] %}

然后您可以使用同一对象的其他属性。所以你的代码正在寻找。

{% for block in section.blocks %}
   {% assign product = all_products[block.settings.product] %}
   {% for image in product.images %} 
     <!-- list images -->
      {{ image.src | product_img_url: 'grande' }} 
     <!-- product title -->
      {{product.title}}
     <!-- product price -->
      {{ product.price | money_without_trailing_zeros }}
     <!-- product description -->
      {{product.description}}
   {% endfor %}   
{% endfor %}

{% schema %}
{
   "name": "Demo",
   "blocks": [
      {
         "type": "new-arrival",
         "name": "New Arrival",
         "settings": [
            {
               "type": "product",
               "id": "product",
               "label": "Product"
            }

         ]
      }
   ]
}
{% endschema %}

您可以查看和阅读有关对象的更多信息 all_products Link

感谢 Onkar 的指导。我更新了一点现在它可以正常工作了。

{% for block in section.blocks %}
   {% assign product = all_products[block.settings.product] %}
   {% for image in product.images %} 
        <img src="{{ image.src | product_img_url: 'grande' }}" >
      {{product.title}}
      {{ product.price | money_without_trailing_zeros }} 
      {{product.description}}
   {% endfor %}
   
{% endfor %}