Hi Shopify Community,
I’m currently implementing a dynamic cart update using the Shopify Ajax API and am encountering an issue where the cart items, the cart icon bubble, don’t visually update without a page reload after a successful POST request.
Here is the code I’m using to update the cart:
await postToCart('cart/add.js', {
items: [{
quantity: 1,
id: VARIANT_ID,
properties: { _custom: true, price }
}],
sections: "cart-items,cart-icon-bubble,main-cart-items,cart-footer",
sections_url: "/cart"
});
I have tried all variations of the sections
param & sections_url: “/cart”
sections: "cart-items", "cart-icon-bubble" , "main-cart-items", "cart-footer",
sections: ["cart-items,cart-icon-bubble,main-cart-items,cart-footer"],
sections: ["cart-items", "cart-icon-bubble" , "main-cart-items", "cart-footer"],
- and many more but to no avail
I’m referencing the Bundled Section Rendering documentation to update the cart sections dynamically, but it’s not triggering a re-render without a page refresh.
Could you provide guidance on how to properly trigger the dynamic updates for these sections, so the cart visually reflects the changes?