PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

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

 July 01, 2022     cart, dropdown, html, shopify     No comments   

Issue

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.


Solution

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>



Answered By - Anupam Mistry
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing