Hello, i have followed the Cart API reference to successfully set a post request that adds items to the cart: https://shopify.dev/docs/api/ajax/reference/cart
However, cart icon (#1) is not being updated with the new quantity?. I have to refresh the page to see cart items being added, I’m using the default theme?
Is there any shortcuts to emit/dispatch new items being added to the cart so these will update automatically on the page? also, the popup (#2) that comes when you add cart items with the normal button, does not pop up either?
I can add “sections” to the request like so: (saw this in the original request from the normal add to cart button)
fetch(window.Shopify.routes.root + `cart/add.js`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'sections': 'cart-notification-product,cart-notification-button,cart-icon-bubble',
'items': [{
'id': window.ShopifyAnalytics.meta.selectedVariantId,
'quantity': 2
}]
})
})
.then(response => {
return response.json();
})
.catch((error) => {
console.error('Error:', error);
});
That will return some HTML, from the response:
"sections": {
"cart-notification-product": "
\n
### CC Was Here\n <dl></dl>
\n
",
"cart-notification-button": "Se indkøbskurv (5)\n
",
"cart-icon-bubble": "\n \n\n\n\nIndkøbskurv
55 varer\n
"
}
Are you supposed to just inject this into the dom? lol…