-
-
Save smaege/fe35538def1473ecdb4cd47f93102a59 to your computer and use it in GitHub Desktop.
Variaatioiden käyttöönotto - Boutique, Milan, Stockholm, Bella
This file contains 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
{% if product.variants_for_legacy.size > 0 %} | |
{% for option in product.options_with_values %} | |
<div class="form-group"> | |
<label>{{ option.title }}</label> | |
<select class="form-control" name="variant-select"> | |
{% for value in option.values %} | |
{% if value.variant %} | |
<option value="{{ value.variant.url }}"{% if value.selected %} selected{% endif %}>{{ value.title }}</option> | |
{% endif %} | |
{% endfor %} | |
</select> | |
</div> | |
{% endfor %} | |
<script> | |
const selectElement = document.querySelectorAll('[name="variant-select"]').forEach(el => { | |
el.addEventListener('change', () => { | |
if (el.value) { | |
window.location.href = el.value; | |
} | |
}) | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment