首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Shopify Slate变体未更新

Shopify Slate变体未更新
EN

Stack Overflow用户
提问于 2017-07-24 22:37:20
回答 1查看 864关注 0票数 1

我有一个主题建立在购物板岩上。我所有的产品都有各种大小和颜色的变化。

这是我的product.liquid部分中的变体代码:

代码语言:javascript
复制
{% 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错误,所以我有点不知所措!

EN

回答 1

Stack Overflow用户

发布于 2017-10-12 05:51:50

确保您的整个部分(schema除外)都包含在

代码语言:javascript
复制
<div data-section-id="{{ section.id }}" data-section-type="product" data-enable-history-state="true" itemscope itemtype="http://schema.org/Product">

并将产品对象json传递给slate脚本

代码语言:javascript
复制
<script type="application/json" data-product-json>
      {{ product | json }}
</script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45283371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档