What is the code to add to cart on debut theme?

New Member
1 0 0

I'm not experienced with code in general, but I've got a custom page up with custom html to list my products.  The products each have buy buttons that call a function with it's product id.

Problem is I don't know what to put in the function to add that product to the cart.  I tried inspecting the button on the products page but couldn't figure it out.

How would I go about this?

Shopify Staff
Shopify Staff
624 63 118

Hi, @RH3438!

Welcome to Shopify Community. My name is Olivia and I work here.

Thanks so much for sharing your question with our network. If I have understood correctly, are you using the Buy Button on a Shopify site? The Buy Button is an amazing solution for external websites that don't include e-commerce functionality, but they can certainly cause unexpected issues if placed within a Shopify site.

Since a Buy Button is like a shortcut for buying one of your products, I might suggest the use of permalinks as suggested above. If you're looking to create a custom collection page, that can be done via custom code without using Buy Button embedded products.

Check out the Buy Button FAQ for more information: 

Let me know if I've misunderstood your question and I'd be glad to chat further.

Warm regards,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Shopify Partner
2789 175 469

Dear @RH3438 

Hope the following solution will help you

  1. From Shopify Admin select Online Store and click on Themes
  2. Choose your main theme
  3. Click the . . . on the top left-right (see below) and hit Edit code
  4. Open Snippets -> product-card-grid.liquid File and paste below code at the end of the page.


<form method="post" action="/cart/add"> 
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
<input min="1" type="number" id="quantity" name="quantity" value="1"/> <input type="submit" value="Add to cart" class="btn" />