All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello I got this code for adding to cart:
try {
const response = await fetch(window.Shopify.routes.root + "cart/add.js", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ items: itemsToAdd }),
});
if (!response.ok) throw new Error("Add to cart failed");
But the code doesnt allow the cart drawer to update directly after adding, instead it waits until you refresh the page to see the correct cart. How can I make the cart update easily after adding?