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.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024