Cart update form

Published

cart_update form modifies the cart content.

Add product to cart

cart_update form can be used for adding products to cart.

{% form 'cart_update' class:'' onSuccess:'/cart' %}
	<input type="hidden" name="product" value="{{product.id}}">
	<input type="hidden" name="quantity" value="1">
	<input type="hidden" name="variant" value="{{product.variants[0].id}}">
	<button 
		name="submit" 
		class="btn {% if product.quantity <= 0 %} btn-disabled{% endif %}"
		{% if product.quantity <= 0 %}disabled{% endif %}
	>
			{% unless  product.quantity <= 0 %}
				 {{ 'Add to cart' | t }}
			{% else %}
				 {{ 'Out of stock' | t }}
			{% endunless %}
		</button>
{% endform %}
Example for add to cart button using the update cart form and redirecting to /cart