How to add "buy now" button on image with variant selection

PamDigital
Excursionist
42 2 7

Hello everyone,

I want to add "buy now" button on my banner image with variant selection. I used shopify's feature "buy now button code" but it is not working well. How can I add buy now button on my end without plugin? 

0 Likes
PamDigital
Excursionist
42 2 7
<div id="product">
  {% form 'product', product, id: "form_buy", name: "form_buy" %}
  <div class="form-group"  {% if product.variants.size == 1 and product.variants.first.title contains 'Default' %}style="display:none"{% endif %}>
    <select name="id" id="productSelect" class="form-control">
      {% for variant in product.variants %}
      {% if variant.available %}
      <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>
      {% else %}
      <option disabled="disabled">
        {{ variant.title }} - {{ 'products.product.sold_out' | t }}
      </option>
      {% endif %}
      {% endfor %}
    </select>
    {% if section.settings.show_variant_swatches != 'false' %}
    {% if product.available and product.variants.size > 1 %}
    {% for option in product.options %}
    {% include 'swatch' with option %}
    {% endfor %}
    {% endif %}
    {% else %}
    <style type="text/css">
      .selector-wrapper {
        display: block;
      }
      #productSelect {
        display: block;
      }
    </style>
    {% endif %}
  </div>
  <div class="form-group">
        {% if section.settings.show_buy_now %}
        {{ form | payment_button }}  
    {% endif %}
  </div>
  {% endform %}
  <!-- end-button -->
</div>


Hello again this code works fine but when I use this code my addtocart button does not response. Anyone can help me ?

0 Likes