I’ve set up a product matrix to add a product with variants to the cart - easy.
I cannot figure out how to add a single simple product to the cart as I’m confused by the following - especially ‘this should be made dynamic’ (for info I think this is why I gave up on Commerce last time)…
#Single Products Form
With the single products form only one product can be added to the cart per request. As the structure of the form is a little easier than the multiple products form, it is easier to use this when providing different products as variations in your catalog.
The form includes:
- an
add_to_cart
hidden input with value 1, this is used to trigger the add to cart logic. - the product ID in a hidden
product
input. This should be made dynamic, for example with the commerce.get_resource_product_id snippet, a TV holding the product ID(s) (like the Commerce Products TV), or a different way that you establish a products’ ID. - the quantity in a
quantity
input
<form method="post" action="[[~[[++commerce.cart_resource]]]]">
<input type="hidden" name="add_to_cart" value="1">
<input type="hidden" name="product" value="123">
<label for="add-quantity">Quantity:</label>
<input type="number" name="quantity" value="1">
<input type="submit" value="[[%commerce.add_to_cart? &namespace=`commerce` &topic=`frontend`]]">
</form>