Custom Add to cart button
Recommended method
<script src="{{ 'product-form.js' | asset_url }}" defer="defer"></script>
<product-form class="product-form" data-section="{{ section.id }}">
<div
id="Product-Form-Error-Message-{{ section.id }}"
class="alert-message alert-error mb-2"
role="alert"
aria-live="assertive"
hidden
></div>
{% form 'product', product, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' %}
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
<input type="hidden" name="quantity" value="1">
<button type="submit" name="add" class="button button--primary">
Add to cart
</button>
{% endform %}
</product-form>Custom JavaScript method
Notes
Last updated