I’m using Simple 1.0 theme. On my homepage, I use several Featured Blocks with 3 pics per row. I saw that the 2.0 Dawn theme Featured Collection blocks have an “Add To Cart” button below the Featured Block pics. Is there a way to add this button into the 1.0 theme?
If there is no setting for this in the theme editor, then it needs to be custom coded.
Hi you can insert a Shopify product form inside each product card. Add this code in product card section file.
<form method="post" action="/cart/add">
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
<button type="submit">Add to cart</button>
</form>`
Hi @faysqs
Can you share the store URL so we can confirm which theme you are referring to?
But you can implement the solution below. Hope this helps.
Go to the edit code and search for these. Open your product grid file (usually one of these):
-
snippets/product-grid-item.liquid
-
snippets/product-card.liquid
-
sections/collection-template.liquid
Paste this inside the product loop (where each product is rendered):
{% if product.available %}
<form method="post" action="/cart/add" class="product-card-form">
<input
type="hidden"
name="id"
value="{{ [product.first_available_variant.id](http://product.first_available_variant.id) }}">
<button type="submit" class="btn add-to-cart-btn">
Add to cart
</button>
</form>
{% else %}
<button class="btn sold-out-btn" disabled>
Sold out
</button>
{% endif %}