Home › Forums › Basel support forum › Prevent Add To Cart button from Double Click
Prevent Add To Cart button from Double Click
- This topic has 7 replies, 3 voices, and was last updated 5 years, 8 months ago by
Artem Temos.
-
AuthorPosts
-
August 20, 2019 at 9:04 am #139374
YogevParticipantHi,
How can i make the ADD TO CART button not clickable anymore after the first click?
It caused many customers to add the same products few times.Thank you very much,
August 20, 2019 at 11:00 am #139383
Elise NoromitMemberHello,
You can try “Sold individually” option https://prnt.sc/ov23fo this option allows one of this item to be bought in a single order. Edit a product and find the option in the Inventory tab.
Best Regards
August 20, 2019 at 11:05 am #139385
YogevParticipantThanks, but this is not the solution im looking for.
Some of my products sold with minimum of 2 pieces.Im just looking for some code that disable the ATC once it clicked. Or to add any Spiner.
August 20, 2019 at 12:08 pm #139406
Elise NoromitMemberHello,
Unfortunately, Woocommerce does not provide such option by default. Our theme does not influence the Woocommerce functions. Perhaps, you can try searching for a plugin.
Best Regards
August 20, 2019 at 12:24 pm #139413
YogevParticipantHi,
I actually try 2 codes. I will appreciate if you can help me here and tell me why they are not working for me
Thanks.
This is the first option:
$( '.add_to_cart_button' ).on( 'click', function(){ $(this).addClass('loading'); }); $(this).removeClass('loading'); block( $( 'div.summary.entry-summary' ) ); unblock( $( 'div.summary.entry-summary' ) ); var is_blocked = function( $node ) { return $node.is( '.processing' ) || $node.parents( '.processing' ).length; }; var block = function( $node ) { if ( ! is_blocked( $node ) ) { $node.addClass( 'processing' ).block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } ); } }; var unblock = function( $node ) { $node.removeClass( 'processing' ).unblock(); };
Second options:
add_action( 'wp_footer', 'custom_trigger_ajax_add_to_cart' ); function custom_trigger_ajax_add_to_cart() { ?> <script type="text/javascript"> (function($){ $('body').on( 'added_to_cart', function(){ jQuery('a.add_to_cart_button').click(function(){ jQuery(this).append('<img src="/spinner.gif" width="20px" height="20px"/>')}); }); })(jQuery); </script> <?php }
August 21, 2019 at 6:18 am #139515
Artem TemosKeymasterSorry, but such customizations are out of our theme support scope and we don’t know how your code is supposed to work.
August 21, 2019 at 6:33 am #139521
YogevParticipantDo you have anyone to recommend me about for those customization i need?
Thanks
August 21, 2019 at 7:33 am #139522
Artem TemosKeymasterWe can suggest you to hire our partners to do this job https://wpkraken.io/?ref=xtemos.studio
-
AuthorPosts
- You must be logged in to create new topics. Login / Register