Anupam Mistry
Anupam Mistry

Reputation: 421

How to add product-title list in dropdown menu on Shopify?

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>
And what if I have multiple dropdowns. When one product is selected in one option, it will be disabled in the second option.

Upvotes: 1

Views: 811

Answers (1)

Anupam Mistry
Anupam Mistry

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

Related Questions