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

Donation for solution | Problems with updating cart after adding to cart

Donation for solution | Problems with updating cart after adding to cart

TrendBlend
Trailblazer
367 0 40

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?

Reply 1 (1)

TrendBlend
Trailblazer
367 0 40