• Following code changes the “Place Order” button text into: “Please Wait” while the order is processing.

    The problem is that if an error message is returned after the button is clicked, the text will still be “Please Wait”.

    If an error message comes in, the text should revert to “Place Order”. How do I check for the error messages?

    add_action( 'wp_footer', 'custom_checkout_jquery_script' );
    function custom_checkout_jquery_script() {
      if ( is_checkout() && ! is_wc_endpoint_url() ) :
    ?>
      <script type="text/javascript">
      jQuery( function($){
          jQuery('form.checkout').on('submit', function(event) {
            jQuery('button#place_order').text('Please Wait');
            event.preventDefault();
          });
      });
    </script>
     <?php
      endif;
    }

    Thanks in advance!

    • This topic was modified 3 years, 2 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How do i check for error messages in WooCommerce?’ is closed to new replies.