So I am trying to loop through a collection that the shopify store user can choose in the settings. Right now everything works if I assign a certain collection but that doesn’t let me change it dynamically.
<div id="slideshow">
<div class="wrapper">
<div class="rslides_container">
<ul class="rslides" id="slider1">
{% assign _collection = collections['new-products'] %}
{% for product in _collection.products %}
<li class="slideshow-item">
<a href="{{ product.url }}"><img src="{{ product.featured_image | img_url: 'medium' | format: 'jpg' }}" alt="{{ block.settings.slide_heading }}"></a>
<h3>{{ product.title }}</h3>
<h4>{{ product.price | money | remove: '.00' }}</h4>
<p>{{ product.description }}</p>
{% include 'buybutton' %}
</li>
{% endfor %}
</ul>
</div><!-- #slideshow-container -->
</div>
</div><!-- #slideshow -->
{% schema %}
{
"name": "Slideshow",
"settings": [
{
"type": "collection",
"id": "feature_collection",
"label": "Chose Collection to show on slideshow"
}
]
}
{% endschema %}
I thought changing the for loop to:
{% for product in collections[settings.feature_collection].products %}
Would work but then it just shows nothing on the slider no matter what collection I choose in the theme customizer. Has anyone done this or know how to do it? Thanks!
2
Answers
I figured it out. I left out one part in the loop statement.
I was missing the word section before .settings
I would try.
{% for product in collection.feature_collection.product%}