All things Shopify and commerce
I want to show the option to select a variant and add to cart button on the product grid item so that product can be added to cart without going to the product page, I can't get the variant picker functionality to work. Can someone help me with the code
Hi @Mmbandooni
I hope you are well. If you are using the Dawn theme, then please change this setting from "none" to "standard" then it will work as requested.
Here is the screenshot for your reference:
Please let me know if it works. Thank you!
Best,
Daisy - Avada Support Team.
i also want to showcase size variant on top of ADD TO CART BUTTON SO people can directly add the variant to the cart how can i do this
Are you using the Dawn theme now? If that product have multiple variant, then it will not display the "add to cart" button. It will show the "choose varient" setting instead.
i want to do this as you can see how the product cart is shown i want exactly like this
To achieve a similar display of variant sizes above the "Add to Cart" button in your Shopify store, you can customize your theme. Here’s how you can implement it:
<div class="variant-options">
{% for variant in product.variants %}
<button class="variant-button" data-variant-id="{{ variant.id }}">
{{ variant.title }}
</button>
{% endfor %}
</div>
.variant-options {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-bottom: 10px;
}
.variant-button {
padding: 5px 10px;
border: 1px solid #ccc;
background: #f9f9f9;
cursor: pointer;
}
.variant-button:hover {
background: #eaeaea;
}
document.querySelectorAll('.variant-button').forEach(button => {
button.addEventListener('click', function () {
const variantId = this.getAttribute('data-variant-id');
const addToCartBtn = this.closest('.product-card').querySelector('.add-to-cart');
addToCartBtn.setAttribute('data-variant-id', variantId);
});
});
NOTE:
Before making any changes to your Shopify theme, always create a backup copy of your theme. This ensures that you have the original version of your theme in case any changes cause issues.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025