• Resolved Bahadir

    (@bhdrr)


    I want to show a loading symbol on Add to Cart button when user clicks it. Currently in my site, when user clicks the button, it do nothing for 2-4 seconds and shows view cart button.

    I want to show some loading or spinning icon during these 4 seconds. Is it possible? can someone guide me?

    https://www.ads-software.com/plugins/woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor royho

    (@royho)

    Are you referring to the shop page? If so, WooCommerce by default already does show a loading status. So perhaps your theme is removing it.

    Thread Starter Bahadir

    (@bhdrr)

    Hey @royho,

    Thanks for reply. You can see in here: https://goo.gl/5plnJq .

    You can click “Sat?n Al” button for test.

    I have also using One page checkout plugin.

    Plugin Contributor royho

    (@royho)

    Then you would need to add custom JS to pull this off. You can try the following:

    jQuery( '.single_add_to_cart_button' ).click( function() {
         jQuery( this ).addClass( 'loading' );
    });

    You can use a plugin like this to add the script https://www.ads-software.com/plugins/custom-css-js-php/

    Thread Starter Bahadir

    (@bhdrr)

    @royho,

    It didn’t work. I’ve added to header.php between head tag. You can see from source-code.

    My code snippet like this:
    <script type=”text/javascript”>jQuery( ‘.single_add_to_cart_button’ ).click( function() {
    jQuery( this ).addClass( ‘loading’ );
    });</script>

    Plugin Contributor royho

    (@royho)

    Try that.

    jQuery( document ).ready( function( $ ) {
        $( '.single_add_to_cart_button' ).click( function() {
              $( this ).addClass( 'loading' );
         });
    });
    Plugin Contributor royho

    (@royho)

    To be honest, looking at your site, I believe this “slow loading” is an underlaying problem which should be addressed rather than using a “band aid”. I constantly see 500 server error on some of your assets while loading pages.

    I would suggest you fix that.

    Plugin Contributor royho

    (@royho)

    Also the code you copied is missing a closing parenthesis and semicolon.

    Thread Starter Bahadir

    (@bhdrr)

    Horray! Working now. Thanks for your help mate ^_^

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to show loading icon on Add to Cart Button’ is closed to new replies.