Product variant selection radio buttons are disallowing (disabling) buy now button

New Member
2 1 0

Hey guys, been stuck on this for ages, so if anyone could help, I'd really appreciate it.

Basically as I didn't want the default size dropdown, I decided radio buttons would be better as I could style them like swatches. I did it like so:




{% for variant in product.variants %}
                <div class="no-select price-button relative {% if variant.available %}stock{% else %}no-stock{% endif %}" id="radio_container_{{ }}" {% if variant.available %}onclick="doSelectVariant('{% if variant.available %}{{ }}{% else %}0{% endif %}'){% endif %}">
                  {% if variant.available %}
                    <div class="hidden"></div>
                  {% else %}
                    <div class="out-of-stock-overlay absolute"></div>
                   {% endif %}
                  <input type="radio" name="id" value="{{ }}" id="radio_{{ }}" class="size-radio" />
                    <label for="radio_{{ }}" class="radio" id="label_for_{{ }}">
                      {{ variant.option1 | escape }}
              {% endfor %}




As for the script it's referencing:




var ps = null;
    window.doSelectVariant = function(variantId) {
      if (ps) {
      ps = document.getElementById("radio_container_" + variantId)
      document.getElementById("radio_" + variantId).click()





Anyway, this actually works fine on the add to cart button. However, the buy now button is greyed out/disabled, there's no javascript event on the buy now button either so removing the disabled classes/attributes means it's clickable, but doesn't send me to checkout at all. Weird scenarios it does work though: If I add to cart, it suddenly becomes avaialable OR if I select a variant then refresh, it becomes available.

My assumption is this is not working for some reason as it's not selecting a default variant? Does anyone have any ideas or any javascript that could assist in sending my customers to the checkout, even if it's some custom stuff.

I'm using Debut and all the product file code is in product-template.liquid, none of the other files

New Member
2 1 0

This is an accepted solution.

Nevermind lads, somehow just doing a default selection on the radios with some simple JS meant it worked, lol. Cheers anyway!