• Resolved berry metal

    (@erikalleman)


    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();
                  });
              });
        
             //To detect woocommerce error trigger JS event
              jQuery( document.body ).on( 'checkout_error', function(){
                        console.warn("error occured!");
                        jQuery('button#place_order').text('Place Order');
                } );
    
    </script>
     <?php
      endif;
    }

    Hi there,

    does anyone know why isn’t this code able to check for the error message?

    It’s replacing the “Place Order” text with “Please Wait” when clicked, and it’s supposed to revert the text back to “Place Order” if an error message is shown upon clicking the button by checking for the error message.

    But the text won’t change back, if an error message is shown.

    I would also like to change the class of text while the order is processing.
    Can someone advise how to do that?

    Thanks in advance,

    Adam

    • This topic was modified 3 years, 2 months ago by berry metal.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @erikalleman

    Please be informed that we are unable to provide support for customizations per our Support Policy.

    I’m going to leave this development topic open for a bit to see if anyone is able to chime in to help you out.

    If you’re not receiving input on this thread, I can recommend reaching out to one of the customization experts listed here: https://woocommerce.com/customizations/.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter berry metal

    (@erikalleman)

    You are refering to WooCommerce employees and their policies, right? As I can see in the link shared.
    I didn’t know that WooCommerce employees reply on this forum or run this forum, I thought that WordPress users do.

    If WooCommerce has their own dedicated paid support via their website, I don’t understand why do they run this forum then? Can someone explain?

    I thought WordPress users run WordPress Forums, not WordPress or WooCommerce employees.

    Thanks in advance.

    Hello there,

    Sorry for the confusion. This forum is open to everyone that’s correct. Kindly note this forum is specific to WooCommerce core, and providing support for custom code is optional.

    If you would like to perform a debug to take a better look, to check if there is something affecting the code to run appropriately, you can refer to this documentation below:

    Debugging in WordPress

    I hope this leads you in the right direction.

    Hi @erikalleman

    If WooCommerce has their own dedicated paid support via their website, I don’t understand why do they run this forum then?

    Just to clarify, if you’re using any of our paid extensions, you are eligible for WooCommerce premium support via email or chat as a WooCommerce.com extensions license holder. You can create a support ticket with us via WooCommerce.com > My Account > Support. You may need to log into your WooCommerce account before you can access that page.

    If you are not using any premium extensions, we are here to support you in this forum, while being limited to the scope of our support policy.

    It seems we’ve not had additional inputs on this thread for the custom code. Thus, we encourage you to make use of the above resources.

    That said, I’ll go ahead and mark the thread as resolved but please feel free to create a new topic if you have further questions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Check for WooCommerce error message and assign class to button text’ is closed to new replies.