Support » Plugin: WooCommerce » Confirm add to cart ajax

  • Resolved yessoftmk

    (@yessoftmk)


    Hi, firstly thanks for best shop!)

    I need make confirm “add to cart ajax”

    In file footer.php I add:

    
    <script>
    
        jQuery( function($) {       
        $('.ajax_add_to_cart').click( function( event ) {
            if( ! confirm( 'Add to cart?' ) ) {
                event.preventDefault();
    	    //event.stopPropagation(); - tryed too
    			 
            }  
    
        });
    });
    </script>
    

    It must work next – https://i.imgur.com/YTgaYyu.png (screenshot)

    but “cancel” not working….add to cart always work….

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Three Sons

    (@3sonsdevelopment)

    Hello @yessoftmk,

    That’s an interesting idea. I tried this with my store and it did appear to work as expected.

    
    <script>
    
    jQuery( function($) {       
        $('.ajax_add_to_cart').click( function( event ) {
            if( ! confirm( 'Add to cart?' ) ) {
                return false;
            }  
        });
    });
    
    </script>
    

    The confirmation popped up each time I clicked add to cart. If I confirmed it, the product was added. If I canceled, then the product was not added to the cart.

    See if that will work for you. Let me know if you have any questions.

    Cheers

    Plugin Support EtienneP

    (@etiennep)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.