Skip to content

Instantly share code, notes, and snippets.

@longdasian
Created May 28, 2021 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longdasian/d2963e463bbd2d59b6d0900e278065cb to your computer and use it in GitHub Desktop.
Save longdasian/d2963e463bbd2d59b6d0900e278065cb to your computer and use it in GitHub Desktop.
{% form 'product', product, class:form_classes, novalidate: 'novalidate', data-product-form: '' %}
{% unless product.has_only_default_variant %}
<div class="product-form__controls-group">
{% for option in product.options_with_values %}
<div class="selector-wrapper js product-form__item">
<p>{{ option.name }}</p>
{% if option.name == "Size" %}
{% assign index = forloop.index %}
<div class="size-selector">
<div class="size-selector__list">
{% for value in option.values %}
{% assign sizeWords = value | split: ' ' %}
{% capture sizeLetters %}{% for word in sizeWords %}
{{ word | slice: 0 }}
{% endfor %}{% endcapture %}
<div class="size-selector__item">
<input
class="single-option-selector-{{ section.id }}"
id="size-{{ forloop.index }}" type="radio" name="size"
value="{{ value | escape }}"
data-index="option{{index}}"
{% if option.selected_value == value %} checked="true"{% endif %} />
<label for="size-{{ forloop.index }}">{{ sizeLetters }}</label>
</div>
{% endfor %}
</div>
</div>
{% else %}
</div>
<label for="SingleOptionSelector-{{ forloop.index0 }}">
{{ option.name }}
</label>
<select class="single-option-selector single-option-selector-{{ section.id }} product-form__input"
id="SingleOptionSelector-{{ forloop.index0 }}"
data-index="option{{ forloop.index }}"
>
{% for value in option.values %}
<option value="{{ value | escape }}"{% if option.selected_value == value %} selected="selected"{% endif %}>{{ value }}</option>
{% endfor %}
</select>
{% endif %}
</div>
{% endfor %}
</div>
{% endunless %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment