Shopify themes, liquid, logos, and UX
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>
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025