# Cart add
A vistior can add a variant to their cart.
# Endpoint
POST
/cart/add
# Fields
Name | Required |
---|---|
id | true |
quantity | false |
clear | false |
return_to | false |
with | false |
# Example
<form action="/cart/add" method="POST">
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
<input type="quantity" name="quantity" value="1">
<input type="hidden" name="return_to" value="/checkout">
<input type="hidden" name="clear" value="products">
<button>Add to cart</button>
{{ csrf.field }}
</form>
id
The id of the variant you want to add to cart.
quantity
The quantity of the variant you want to add to cart. Defaults to 1
of not specified.
clear
The clear input can have one of these three values 1
, product
, products
.
1
- Clear the full cart incl. any rows and discounts.product
- Clear the cart for any rows that has a variant from the same product that you are adding to the cart.products
- Clear the cart for all existing products, but keep any discounts.
return_to
Specify where the customer should be redirected after submitting the form.
Defaults to /cart
.
with
Add sub-rows to the cart (further documentation missing)