主页添加到购物车中选定Shopify的特定变体

时间:2020-02-12 14:32:30

标签: ajax shopify cart variant

我已在要构建的部分的“添加到购物车”表单中添加了一个变体选择器,但无法找到一种方法来获取选择该特定变体的方式来更改提交给购物车/的“ id” add.js。

https://qknwir79ybx50ydw-20061455.shopifypreview.com是预览链接,它是一个产品轮播,在产品下方带有“添加到购物车”按钮。

有人知道选择了正确的变体后如何激活吗?

关于ShowTime主题。

这是我的选择器代码:

{% unless all_products[product].options.size == 1 and all_products[product].variants[0].title == 'Default Title' %}
{% for option in all_products[product].options_with_values %}
<div class="col-md-4 selector-wrapper main-product-select">

<label {% if option.name == 'default' %}class="hidden" {% endif %} for="product-select-{{ option.name }}">
{{ option.name }}
</label>
<select class="single-option-selector" id="SingleOptionSelector-{{ forloop.index0 }}">
{% for value in option.values %}
{% unless value contains "% off" %}
<option {% if option.selected_value == value %}selected{% endif %}>
{{ value }}
</option>
{%endunless%}
{% endfor %}
</select>

</div>
{% endfor %}
{% endunless %}
<select name="id" id="product-select-{{ all_products[product].id }}" class="product-variants form-control hidden">
{% for variant in all_products[product].variants %}

<option {% if variant == all_products[product].selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>

{% endfor %}
</select>

0 个答案:

没有答案