Shopify Code - Sample Code - Include Multiple Blocks In Shopify Section Schema

Sample Code – Include Multiple Blocks In Shopify Section Schema

0 Shares
0
0
0
0
0
0
0
{% schema %}
  {
    "name": "Multiple Blocks",
    "blocks":[
      {
        "type": "block-1",
        "name": "Block 1",
        "settings": [
          {
            "type": "text",
            "id": "title",
            "label": "Title"
          }
        ]
      },
      {
        "type": "block-2",
        "name": "Block 2",
        "settings": [
          {
            "type": "text",
            "id": "title",
            "label": "Title"
          }
        ]
      }
    ]
  }
{% endschema %}

{% for block in section.blocks %}
  {% if block.type == 'block-1' %}
    <h2>{{block.title}}</h2>
  {% elsif block.type == 'block-2' %}
    <h3>{{block.title}}</h3>
  {% endif %}
{% endfor %}