97
rated 0 times
[
99]
[
2]
/ answers: 1 / hits: 29186
/ 12 Years ago, tue, december 18, 2012, 12:00:00
The Ajax seems to work just fine but the cart content won't refresh as expected. I want the contents of the cart to be refreshed once the add to cart button is clicked.
As it is now, I have to refresh the page manually to see the added products.
I'm using this function to add a product to my woocommerce cart:
function addToCart(p_id) {
jQuery.ajax({
type: 'POST',
url: '/wp/?post_type=product&add-to-cart='+p_id,
data: { 'product_id': p_id,
'quantity': amount},
success: function(response, textStatus, jqXHR){
console.log(Product added);
}/*,
dataType: 'JSON'*/
});
}
jQuery('#addToCart').click(function(e) {
e.preventDefault();
addToCart(prod_id[product_id]);
return false;
});
Is it possible to refresh only the cart after a product was added?
More From » jquery