Reputation: 425
I'm working on a "bundling" feature for my store and would like to show all my products within a custom form field.
I would like there to be a dropdown menu showing the title and primary image for each product.
I'm thinking the code should be something like this:
<p class="line-item-property__field">
<label>bundled item</label><br>
<select required class="required" id="bundled-item" name="properties[bundled item]">
{% for product in collections.products %}
<option value="{{ product.title }}">{{ product.title }}{{ product.featured_image }}</option>
{% endfor %}
</select>
</p>
That doesn't quite do it though. Can anyone show the proper way to embed products within a dropdown?
Upvotes: 1
Views: 1566
Reputation: 2925
Try this
{% for product in collections['all'].products %}
<option value="{{ product.title }}">{{ product.title }}{{ product.featured_image }}</option>
{% endfor %}
But remember, only a maximum of 1000 items can be called in a loop; by default it is 50.
Upvotes: 2