Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify AJAX Section Rendering API updates line items but doesn't update cart total

Shopify AJAX Section Rendering API updates line items but doesn't update cart total

Francis_Kolms
Shopify Partner
4 1 2

I'm trying to update cart items with AJAX and Section Rendering API within the Dawn theme.

When I execute the code below in the cart page all works well on product item level - the quantity updates and the price changes accordingly without page reload. However, the totals in cart-footer don't update.

Anyone could let me know what is wrong with the code below?

 

 

 

 

let body = JSON.stringify({
  updates: {
    43222573449472: 2 
  },
  "sections":[
    "template--16499219595520__cart-items",
    "cart-icon-bubble",
    "cart-live-region-text",
    "template--16499219595520__cart-footer"
  ]
});

fetch('cart/update', {...fetchConfig(), ...{ body }})
  .then((response) => {return response.text();})
  .then((state)=>{
  const parsedState = JSON.parse(state); 
  document.getElementById('shopify-section-template--16499219595520__cart-items').innerHTML = parsedState.sections['template--16499219595520__cart-items'] 
})

 

 

 

 

 

Replies 0 (0)