2016-07-30 43 views
0

我想在我的集合页面上有添加到购物车按钮(例如 - example.com/collections/collection-name)在每个产品旁边。所以如果我在页面上有20种产品,我想要在他们各自的产品旁边有20个加入购物车按钮。Shopify:添加到购物车按钮只在集合页面上添加最后一个产品

我编辑产品card.liquid下列要求:

 <select name="product-form-{{ product.variants.first.id }}" id="product-form-{{ product.variants.first.id }}" class="product-form__variants"> 
     {% for variant in product.variants %} 
      <option {% if variant == current_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}" {% unless variant.available %} disabled="disabled" {% endunless %}> 
      {% if variant.available %} 
       {{ variant.title }} - {{ variant.price | money_with_currency }} 
      {% else %} 
       {{ variant.title }} - {{ 'products.product.sold_out' | t }} 
      {% endif %} 
      </option> 
     {% endfor %} 
     </select> 
     <div class="product-form__item product-form__item--quantity"> 
     <label for="Quantity">{{ 'products.product.quantity' | t }}</label> 
     <input type="number" id="Quantity-{{ product.variants.first.id }}" name="quantity" value="1" min="1" class="product-form__input"> 
     </div> 
     <div class="product-form__item product-form__item--submit"> 
     <button name="add" class="btn btn--full product-form__cart-submit"> 
      <span id="AddToCartText-{{ product.variants.first.id }}">{{ 'products.product.add_to_cart' | t }}</span> 
     </button> 
     </div> 
    </form> 

的问题是,当我点击加入购物车1号产品的页面,最后的产品。在页面上被添加到购物车。

添加到购物车的现有onclick事件是否可以找到页面上的最后一个产品ID并将其添加到购物车?我正在使用Venture主题。

我错过了什么?

回答

0

表单打开在哪里? 它应该在第一次选择之前。

相关问题