0

I'd like to add a digital product to the cart using a radio input but all the template examples I see use select. Is it possible to use a radio input?

With Select (working):

<select name="purchasableId">
  {% for digitalProduct in entry.fontProducts.all() %}
    <option value="{{digitalProduct.purchasableId}}">{{digitalProduct.slug}}</option>
  {% endfor %}
</select>

With radio inputs (not working):

{% for digitalProduct in entry.exampleProducts.all() %}
  <li>
    <div>
      <input 
        type="radio"
        name="product"
        value="{{digitalProduct.purchasableId}}" />
    </div>
  </li>
{% endfor %}
2

The name for your input needs to be purchasableId:

{% for digitalProduct in entry.exampleProducts.all() %}
  <li>
    <div>
      <input 
        type="radio"
        name="purchasableId"
        value="{{digitalProduct.purchasableId}}" />
    </div>
  </li>
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.