我有一个主题建立在购物板岩上。我所有的产品都有各种大小和颜色的变化。
这是我的product.liquid部分中的变体代码:
{% unless product.has_only_default_variant %}
{% for option in product.options_with_values %}
<div class="selector-wrapper js">
<label for="SingleOptionSelector-{{ forloop.index0 }}">
{{ option.name }}
</label>
<select id="SingleOptionSelector-{{ forloop.index0 }}"
class="single-option-selector" data-single-option-selector data-index="option{{ option.position }}">
{% for value in option.values %}
<option
value="{{ value | escape }}"
{% if option.selected_value == value %}selected="selected"{% endif %}>
{{ value }}
</option>
{% endfor %}
</select>
</div>
{% endfor %}
{% endunless %}
<select name="id" class="" data-product-select>
{% for variant in product.variants %}
<option
{% if variant == current_variant %}selected="selected"{% endif %}
{% unless variant.available %}disabled="disabled"{% endunless %}
value="{{ variant.id }}">
{{ variant.title }}
</option>
{% endfor %}
</select>从variant.js和product.js中的代码看,前两个selects的值应该用来更新最后一个,但由于某种原因,这并没有发生。这两个文件中的代码没有更改,而且我在控制台中也没有得到任何JS错误,所以我有点不知所措!
发布于 2017-10-12 05:51:50
确保您的整个部分(schema除外)都包含在
<div data-section-id="{{ section.id }}" data-section-type="product" data-enable-history-state="true" itemscope itemtype="http://schema.org/Product">并将产品对象json传递给slate脚本
<script type="application/json" data-product-json>
{{ product | json }}
</script>https://stackoverflow.com/questions/45283371
复制相似问题