All things Shopify and commerce
I'm using the "embed on a website" feature on my products from Shopify Lite. The Buy button allows the user to add products to the cart without selecting variants. I reached out to support and they said there is no function to force a selection, and they offered up some javascript for me. It doesn't work, and I've tried to modify it to make it work, but I don't really know what I'm doing. Here's the code from Shopify support:
document.querySelector('button[name="add"]').addEventListener('click', function(event) {
var selectElement = document.querySelector('select[name="id"]');
if ([selectElement.value](http://selectElement.value) === '') {
event.preventDefault();
alert('Please select a variant before adding to cart.');
}
});
Can anyone help with this? Thank you.
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