cart does not refresh after adding products

Topic summary

A developer is experiencing an issue where products added to cart via a custom fetch request to /cart/add.js don’t appear in the cart drawer until the page is manually refreshed.

Current Implementation:

  • Using a POST request with JSON body containing items: productsToAdd
  • Cart drawer fails to update automatically after successful addition

Proposed Solution:

  • Add location.reload() after the fetch request to force a full page refresh
  • This provides immediate functionality but reloads the entire page

Status:
The issue remains open. The suggested workaround addresses the symptom but doesn’t achieve dynamic cart updates without page reload, which would require additional development work to trigger the cart drawer’s native refresh mechanism.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hello, I’m using this code to add products to cart, but I have to refresh in order to see them in my cart or cart drawer. Is there an easy way to refresh the cart drawer after adding the product to cart, like with the regular add to cart button? URL:Glow Curtain: 400 LED Lights for a Magical Ambiance – InteriorGlows

fetch('/cart/add.js', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ 
      items: productsToAdd
    }),
  })

Thanks in advance

After doing this code you can add code to refresh page by itself with location.reload()

This will reload the entire page but at least you dont have to do it manually. If you are looking for solutions that changes data dynamically without needing to refresh that will need some good amount of looking up and coding. location.reload() is a quick workaround.