Support » Plugins » Call ajax function when clicking add to cart button on external product page

  • Hi,
    My goal is to open popup with result returned from ajax call, when a user clicks add to cart button on external product page. (while new tab is open with external url too)
    How to do it correctly?
    Thanks in advance.

    P.S. I tried to add a plugin with enqueued js script. It doesn’t work.

    $('.single_add_to_cart_button').click( function(event) {
    
    	$.ajax({
    		url: shopnow.ajax_url,
    		type: 'post',
    		data : {
    			action: 'actionName'
    		}
    		success: function( response ) {
    			alert( 'Response is: ' . response);
    		}
    	})
    	event.preventDefault();  
    })
  • The topic ‘Call ajax function when clicking add to cart button on external product page’ is closed to new replies.