Hello,
I’ve an issue regarding the cart total which does not update when I’m updating an item quantity using Ajax. Basically, I’m changing the quantity of an item based on the user cart content. I’ve attached my code below. The update is reflect in the cart subtotal only when I refresh the page. Correct me if I’m wrong but the goal of using the AJAX request is to not have the page reload right ? So why when the request returns a successful response the cart total is not updated as it should and I still need to reload the page ?
I’ve noticed that the response of the request contains the correct cart informations. But it seems that I need to reload the cart page for the information to be displayed. What can I do to prevent this behaviour an have the updated cart displayed once ?
Thank you !
if (( cartItems.length >= 1 ) && (counter > 1)){
let multiplier = 2 + counter
cartUpdates = { {{ variant_id }}: multiplier}
var params = {
type: 'POST',
url: '/cart/update.js',
data: { updates: cartUpdates },
dataType: 'json',
success: function(response) {
let disp = multiplier*1.99
for (let j=0; j