Here’s what I wrote to prevent add to cart form submission on product detail page, I intended to show a custom message or alert if some custom fields are empty, the strange thing is no matter what I tried, it still submits the form when clicking add to cart button, i don’t know what is wrong: document.addEventListener('DOMContentLoaded', function () { const productForm = document.querySelector('form[action^="/cart/add"]'); if (productForm) {...
Originally asked by JojoLapin45 on Stack Exchange (stackoverflow) (CC BY-SA 4.0).