Code Discount not applying in Cart but applying in Checkout

I’m developing a Shopify app with an app embed/block that automatically applies discount codes based on certain conditions.

I’m doing this by sending a fetch to /discount/{code}.
This returns a redirect. I assume a discount is applied now.

But its not shown in the cart. If I fetch /cart.js the cart items does not have discount applications. When I open the checkout page I see the discount applied. The weird thing is once I open a checkout, I see that the original /cart.js is now updated to have the discount shown and theme shows discount as well

Simplified:

  • I apply discount using fetch("/discount/{code}")
  • When fetching /cart.js initially, the response doesn’t include discount applications
  • After visiting checkout and returning to cart, the same /cart.js endpoint now includes the discount information

Questions

  1. Why is the discount not immediately visible in the cart on my live theme?
  2. Is there a step I’m missing after the /discount/{code} fetch to ensure the cart UI updates?

Issue resolved!

In my case there was an app called Monk on this theme doing something with the cart. Disabling the app got it to work!