<script> const form = document.querySelector('#product_form_7657105784993'); const btn = form.querySelector('[type=submit]'); form.addEventListener('submit', (e) => { e.preventDefault(); btn.innerHTML = '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>'; fetch('/cart/add.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: form.querySelector('[name=id]').value, quantity: 1, }), }) .then(() => { const event = new Event('ajaxProduct:added'); document.dispatchEvent(event); }) .finally(() => { btn.innerHTML = 'Proceed to secure checkout'; }); }); </script>
S