Add to cart button ignores selected variant

Add to cart button ignores selected variant

riciacom
Visitor
1 0 0

Hi,

I'm developing a custom Liquid snippet for product pages to display two complementary products and provide a mechanism to add them to the cart.

I've successfully implemented this using the classic product form, but to avoid a page redirect, I'm utilizing the render function to incorporate the buy buttons from the Dawn theme, enabling the use of the popup cart.

However, I'm encountering an issue: the current implementation only adds the first variant of the product to the cart. I'm unable to resolve this and would greatly appreciate any suggestions.

 

Here is the code for the product form: 

          <form method="post" action="/cart/add" accept-charset="UTF-8" class="form" enctype="multipart/form-data" novalidate="novalidate" data-type="add-to-cart-form">
            <!-- Variant selection -->
            {% if product.variants.size > 1 %}
            <select name="id" class="variant-select">
              {% for variant in product.variants %}
              <option value="{{ variant.id }}">
                {{ variant.title }}
              </option>
              {% endfor %}
            </select>
            {% endif %}
            <!-- Add to cart button -->
            {% render: 'buy-buttons' %}
          </form>
Replies 0 (0)