我想知道是否可以删除特定的产品选项下拉列表,并将其显示在<p>标记或普通字符串中?想象一下,我有三个产品选择:
我们都知道,所有这些选项都将显示在下拉菜单中。如果我想将Size选项显示为一个普通的字符串或文本,会怎么样呢?我们怎么能做到呢?
这是一张图片,让它更清晰。

product.liquid
<select name="id" id="ProductSelect" class="product-single__variants">
{% for variant in product.variants %}
{% if variant.available %}
<option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }} </option>
{% else %}
<option disabled="disabled">
{{ variant.title }} - {{ 'products.product.sold_out' | t }}
</option>
{% endif %}
{% endfor %}
</select>发布于 2016-10-30 11:37:19
我刚找到了答案。我会把它张贴在这里,以帮助与我一样的问题的其他人。
在product.liquid中:
<!-- product options -->
{% capture option_titles %}Size,Flavor{% endcapture %}
{% assign option_titles = option_titles | split:',' %}
{% for option in product.options %}
{% if option_titles contains option %}
{% capture option_index %}option{{ forloop.index }}{% endcapture %}
{% assign option_values = product.variants | map: option_index | uniq %}
{% if option == 'Flavor' and option_values.size > 1 %}
<label for="option">{{ option }}</label>
{{ option_values | join:', ' }}
{% elsif option_values.size == 1 %}
<label for="option">{{ option }}</label>
{{ option_values }}
{% endif %}
{% endif %}
{% endfor %}
<!-- end product options --->发布于 2016-10-29 18:41:41
您必须修改product.liquid模板,而不是下拉列表,您必须将其创建为LI或Text,然后设置为LI或Text。
https://stackoverflow.com/questions/40284337
复制相似问题