BLOG

Buy now/ Add to cart button shopify 2.0 collection page

<product-form class="product-form" id="add-to-cart">
       {%- form 'product', product_card_product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}
       <input type="hidden" name="id" value="{{ product_card_product.selected_or_first_available_variant.id }}">
       {{ form | payment_terms }}
       <input type="hidden" name="id" value="{{ product_card_product.selected_or_first_available_variant.id }}">
       <div class="product-form__buttons">
     <button
                 type="submit"
                 name="add"
                 class="product-form__submit button button--full-width button--secondary btn-add-11"
                 {% if product_card_product.selected_or_first_available_variant.available == false %}disabled1{% endif %}
                 >
           {%- if product_card_product.selected_or_first_available_variant.available -%}
           buy now
           {% else %}
           sold out
           {%- endif -%}
           
         </button> 
         {%- if product_card_product.selected_or_first_available_variant.available -%}
         <a href="https://emoll-homepage-18.myshopify.com/cart/{{product_card_product.selected_or_first_available_variant.id  }}:1?">buy now</a>
      {% else %}
           sold out
           {%- endif -%}
       </div>
       {%- endform -%}
       </product-form>
Share:

Post a Comment!