Skip to content

Instantly share code, notes, and snippets.

@marioloncarek
Created September 5, 2018 09:18
Show Gist options
  • Select an option

  • Save marioloncarek/3df2b9d227ce1a6a8bca07b0ea8aa0d8 to your computer and use it in GitHub Desktop.

Select an option

Save marioloncarek/3df2b9d227ce1a6a8bca07b0ea8aa0d8 to your computer and use it in GitHub Desktop.
Shopify collection blocks
<section class="collection-blocks">
{% for block in section.blocks %}
{%- assign collection = collections[block.settings.collection] -%}
{% if block.settings.collection-title != blank %}
<h2 class="collection-blocks__collection-title">{{ block.settings.collection-title | escape }}</h2>
{% else %}
<h2>{{ collection.title }}</h2>
{% endif %}
{% for product in collection.products limit: 6 %}
<a href="{{ product.url | within: collection }}" class="single-product">
{% if product.featured_image != blank %}
<div class="single-product__image">
{% include 'responsive-image' with
image: product.featured_image,
max_width: 480,
max_height: 480 %}
</div>
{% endif %}
<p>{{ product.title | escape }}</p>
</a>
{% endfor %}
{% endfor %}
</section>
{% schema %}
{
"name":"Collection Blocks",
"settings":[
],
"blocks": [
{
"type": "select",
"name": "Add Collection",
"settings": [
{
"type":"text",
"id":"collection-title",
"label":"Collection title"
},
{
"id":"collection",
"type":"collection",
"label":"Chose Collection"
}
]
}
],
"presets":[
{
"name":"Collection Blocks",
"category":"Collection",
"blocks": [
{
"type": "select"
}
]
}
]
}
{% endschema %}
{% section 'collections-blocks' %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment