php - Prevent multiple clicks on add to cart button - wordpress/woocommerce

one text

Solution:

One thing you could do is to disable the button on click instead of on submit.

Let me know if the code below helps.

Mods The code is only as a guide, I will delete the answer once OP confirms this helps or not.

jQuery(document).ready(function($) {

  $('#submitBtn').on('click', function() {
    console.log('disabling');
    $(this).attr('disabled', 'disabled');
    console.log('disabled');

    // then submit your form
  });
  /*
    $('.cart').one('submit', function() {
      $(this).find('button[type="submit"]').attr('disabled', 'disabled');
    });
    */
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button id="submitBtn" type="submit">Checkout</button>

Source