Hi!
We have a custom code for an “accept terms and conditions” box in our checkout. It’s been working up until recently, but now customers can bypass it without checking the box.
Can someone help me understand why?
var submit = document.querySelector(‘form button.Cart__Checkout’),
terms = document.querySelector(‘[data-terms]’),
popup = document.querySelector(‘.js-popup’);
if (submit) {
submit.addEventListener(‘click’, function(e) {
if (!terms.checked) {
e.preventDefault();
popup.classList.add(‘open’);
}
Hello @Michelle_BS ,
Try this script:
var submitButton = document.querySelector('form button.Cart__Checkout'),
termsCheckbox = document.getElementById('js-terms');
// Initially disable pointer events on the button
submitButton.style.pointerEvents = 'none';
// Listen for changes on the checkbox
termsCheckbox.addEventListener('change', function() {
if (termsCheckbox.checked) {
// Enable pointer events when the checkbox is checked
submitButton.style.pointerEvents = 'auto';
} else {
// Disable pointer events when the checkbox is unchecked
submitButton.style.pointerEvents = 'none';
}
});
Hi!
Should it be inserted the same place? I just tried, but I can still bypass it…
You need to remove your code and then paste the new code.
I tried, but unfortunately it didn’t work. It removed some of the products and removed the show cart funciton