【发布时间】:2020-05-14 09:01:19
【问题描述】:
我试图在 for 循环之外的 Shopify 中显示所选值。 如何在“颜色:”之后的标签中显示选定的单选选项?我想将它显示在“显示选择的选项”的位置。
有人知道怎么解决吗?
<label>Color: SHOW SELECTED OPTION</label>
<fieldset class="single-option-color-selector"
id="ProductSelect-option-{{ forloop.index0 }}">
{% assign option_index = forloop.index %}
{% for value in option.values %}
{% assign variant_label_state = true %}
{% if product.options.size == 1 %}
{% unless product.variants[forloop.index0].available %}
{% assign variant_label_state = false %}
{% endunless %}
{% endif %}
<input type="radio"
{% if option.selected_value == value %} checked="checked"{% endif %}
value="{{ value | escape }}"
data-index="option{{ option_index }}"
name="color"
class="single-option-selector__radio"
id="ProductSelect-option-{{ option.name | handleize }}-{{ value | escape }}">
<label class="option-color-{{ value | escape }}" for="ProductSelect-option-{{ option.name | handleize }}-{{ value | escape }}" title="{{ value | escape }}">{{ value | escape }}</label>
{% endfor %}
</fieldset>
【问题讨论】:
-
我的回答有帮助吗?
标签: loops variables shopify liquid