我有多个产品,每个产品都有多个图像。我只想在Shopify分区页面上显示一张带有描述和价格的图片。这是我的密码。
{% for block in section.blocks %}
{% assign product = all_products[block.settings.product] %}
{% for image in product.images %}
<img src="{{ image.src | product_img_url: 'master' }}" >
{{ product.price | money_without_trailing_zeros }}
{{product.description}}
{% endfor %}
{% endfor %}
{% schema %}
{
"name": "Demo",
"blocks": [
{
"type": "new-arrival",
"name": "New Arrival",
"settings": [
{
"type": "product",
"id": "product",
"label": "Product"
}
]
}
]
}
{% endschema %}
{% for block in section.blocks %}
{% assign product = all_products[block.settings.product] %}
{% if product.featured_image %}
<img src="{{ product.featured_image.src | product_img_url: 'master' }}" >
{% else %}
<img src="{{ product.images[0].src | product_img_url: 'master' }}" >
{% endif %}
{{ product.price | money_without_trailing_zeros }}
{{product.description}}
{% endfor %}
{% endfor %}