How to use AJAX to update Shopping Cart Item Count
-
WPEC 3.8.9.5
Gold Cart 2.9.7I know, I’m missing probably very basics of PHP and AJAX and this might be a lame question. Never mind, I’ve got following JS/jQuery code to invoke an AJAX when visitor clicks any of the Add to Cart buttons
// Update the number by shopping cart icon when item is added to the cart function itemCount() { $.ajax( { url : "cart-count.php", type : "POST", data : "id=1", success : function(msg) { alert (msg); //or use data string to show something else } }); } $(document).on('click', 'input.wpsc_buy_button', itemCount );
I also have following PHP code
$cart_count = wpsc_cart_item_count();
How can I call the PHP code via AJAX and store its result in a JS variable, so I can place it somewhere in front-end of header of my website?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to use AJAX to update Shopping Cart Item Count’ is closed to new replies.