Skip to content

Instantly share code, notes, and snippets.

@wickywills
Last active August 19, 2020 06:35
Show Gist options
  • Save wickywills/0ec0b52b30237691af7bc5197b0e4fa3 to your computer and use it in GitHub Desktop.
Save wickywills/0ec0b52b30237691af7bc5197b0e4fa3 to your computer and use it in GitHub Desktop.
## Working locally
https://www.shopify.com/partners/blog/95401862-3-simple-steps-for-setting-up-a-local-shopify-theme-development-environment
## Basics
### Conditional
```
{% if user.name == 'elvis' %}
Hey Elvis
{% endif %}
```
## Collections
Loop through products in any collection
```liquid
{% for product in collections["handle-name"].products %}
{{ product.title }}
{% endfor %}
```
## Repeatable field (using Advanced Custom Fields plugin)
```
<h1 class="wmco-image-text__heading">Våra läderkuddar</h1>
{% for image in page.metafields.image-text.image %}
{% assign image_index = forloop.index %}
{% for text in page.metafields.image-text.text %}
{% assign text_index = forloop.index %}
{% if image_index == text_index %}
<div class="wmco-image-text">
<div class="wmco-image-text__image" style="background-image:url('{{image}}');"></div>
<div class="wmco-image-text__text">
<div class="wmco-image-text__text-inner">{{text}}</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endfor %}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment