skip to Main Content
{% 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 %}

Can anyone tell me how can I call multiple product images, product details, and product prices on the section page?
Here some code that I try but it’s not correct.

2

Answers


  1. Chosen as BEST ANSWER

    Thank You for guide Onkar. I update a little bit now it properly works.

    {% 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 %}


  2. when using the input type product into Shopify schema, you need to use the all_products object to get the details of the selected product, you need to get the details and assign it to a variable, something like this one.

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

    Then you can use the other properties of the same object. so your code is looking.

    {% 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 %}
    

    You can check and read more about object all_products Link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search