Select a product inside a radio list and add it to cart


I’m trying to select a product inside a radio list and add it to cart but I missing something because it doesn’t work.
Here the front-end :

Here my form :

  <form method="post" action="[[~[[++commerce.cart_resource]]]]" class="add-to-cart">
    <input type="hidden" name="add_to_cart" value="1" />
    <input type="hidden" name="link" value="[[*id]]" />
    <div class="product-quantity">
       <label for="add-quantity">Quantité</label>
       <input type="number" id="add-quantity" name="quantity" value="1" />
    <input type="submit" class="btn cta-button" value="Ajouter au panier" />

And finally my product_as_radio template :

<input type="radio" name="[[+name]]" id="[[+name]]" value="[[+id]]"><label for="[[+name]]" /> [[+name]] &sdot; [[+price_formatted]]</label><br />

The generated HTML looks good, with good products ID etc… but after adding a drink, the cart is openning but the drink is not there !

What did I miss ?

In the radio input, name should be product instead of [[+name]].

thanks, it’s working like a charm now :slight_smile:

1 Like