Menu Close

How to add add to cart button in Shopify

  1. Knowledge Base
  2. Shopify

Shopify is robust eCommerce platform with a complete package of what one needs to be successful in
selling products and services online. Add to cart button is at the center of entire Shopping experience. It
is the starting point for the checkout process.

Steps to add “Add to Cart” button in your Shopify store

  • Navigate to the theme section in your Shopify admin panel
  • Choose “Edit code” in the “Actions” drop-down – Current theme section
    It will open the Shopify Theme Editor
  • Choose the file where you intend to add “Add to Cart button”
  • Copy and paste following code where you need to add “Add to Cart” button.

<form action="/cart/add" method="post" id="product-form- {{ product.id }}">
<input type="hidden" name="id" value="{{ product.variants.first.id }}">
<div>
<button type="submit" name="add">Add to cart</button>
</div>
</form>

  • Click Preview button to check the changes
  • Click Save to complete the process of adding an Add –to-Cart button.

When any customer performs add to cart function, certain Shopify themes would take customers to
your Shopify cart page. To let customers stay on the same product we need to use AJAX to perform this
function. Click here to know more about how to stay on the Product page when items added to cart

 
 

Smiley face




Leave a Reply

Your email address will not be published. Required fields are marked *