1.首先结合Shopify提供的Shopify Ajax API来实现;
<div class="promotionDiscount" data-id="{
{ section.settings.promotionDiscount_id }}">
<div class="promotionDiscount_conter container">
<div class="promotionDiscount_title">{
{ section.settings.promotionDiscount_title }}</div>
<div class="promotionProduct_box">
{% for block in section.blocks %}
<div class="promotionProduct_list" >
<div class="promotion">{
{ block.settings.promotion }}</div>
{%- render 'product-item', product: block.settings.promotionProduct -%}
<div class="promotionProduct_list_bottom">
<div class="promotionProduct_list_num">
<button type="button" class="promotion_reduce promotion_icon" disabled >-</button>
<input id="promotion_num" class="promotion_num" name="quantity" type="text" value="1">
<button type="button" class="promotion_add promotion_icon">+</button>
</div>
{% if block.settings.promotionProduct.available == true %}
{% if block.settings.method == 'cart' %}
<div class="promotionButton promotionButton_cart" data-variants="{
{ block.settings.promotionProduct.variants[0].id }}">
{
{ block.settings.button }}
<svg