Is there a way to update the cart using ajax?
I've tried something like:
$('span.quick-cart-add>p>a').click(function(e){
e.preventDefault();
var data = {};
data["purchasableId"] = $(this).data("id");
data["qty"] = $(this).data("qty");
data[window.csrfTokenName] = window.csrfTokenValue;
$.post( "/actions/commerce/cart/updateCart", data, function(response) {
alert( "success" );
}).always(function(response) { console.log(data, response); });
});
I've tried passing "lineItemId"
instead of "purchasableId"
, and also sending to "/actions/commerce/cart/updateLineItem"
, they all return response.success
but the cart is never actually updated.
Am I not sending the right amount of fields/values, or is there something I'm missing when trying to accomplish this via ajax?