Created
July 27, 2013 22:06
-
-
Save zakhardage/6096473 to your computer and use it in GitHub Desktop.
Auto-selecting the first available variant so that your product does not look sold out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <select id="product-select" name="id"> | |
| {% assign selected = 'notYet' %} | |
| {% for variant in product.variants %} | |
| {% if variant.available and selected == 'notYet' %} | |
| <option value="{{ variant.id }}" selected="selected">{{ variant.title }}</option> | |
| {% assign selected = 'alreadySelected' %} | |
| {% else %} | |
| <option value="{{ variant.id }}">{{ variant.title }}</option> | |
| {% endif %} | |
| {% endfor %} | |
| </select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment