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?