Accept terms and conditions - code not working

Topic summary

A Shopify store owner reports that their custom “accept terms and conditions” checkout code has stopped functioning—customers can now proceed without checking the required box.

Troubleshooting Attempted:

  • A community member provided an alternative JavaScript solution that disables pointer events on the checkout button until the terms checkbox is checked
  • The suggested code listens for checkbox changes and toggles button interactivity accordingly

Current Status:

  • The proposed fix did not resolve the issue
  • When implemented, it caused additional problems: removed the shopping cart display function and some products disappeared
  • The issue remains unresolved and the store owner is seeking further assistance

Note: The code snippets in the thread appear reversed/encoded, making technical analysis difficult without seeing the actual implementation.

Summarized with AI on November 6. AI used: claude-sonnet-4-5-20250929.

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