Reputation: 421
I have multiple products in the Shopify store, so I just create one dropdown menu while purchasing. But I don't know the correct code about how to select products by their title.
<label for="{{ formId }}-product-one">Select product*</label>
<select>
{% for value in product_option.values %}
<option {% if product_option.selected_value == value %}selected{% endif %}>
{{ value }}
</option>
{% endfor %}
</select>
Upvotes: 1
Views: 811
Reputation: 421
This is what I need.
<label for="{{ formId }}-product-one">Select product*</label>
<select>
{% for product in collections['all'].products %}
<option value="{{ product.title }}">{{ product.title }}</option>
{% endfor %}
</select>
Upvotes: 1