Shopify App Block Apply Discount to Cart

Topic summary

A developer is building a Shopify app block for the home page that generates discount codes based on user interaction. They need to apply these discount codes to the cart programmatically but cannot find relevant API documentation.

The main challenge is identifying the correct APIs to interact with the cart and add discount codes from an app block context.

One potential workaround mentioned involves using discount shareable links and redirecting users back to the home page, though the developer is seeking the optimal approach.

The discussion remains open with no confirmed solution yet.

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

I’m building an app block that a user can interact with, and will give out discount codes depending on the interaction

i’d like to apply the discount code from the app block, which lives in the home page of a Theme.

I cannot find documentation on what apis to use to interact with the cart to add discount codes, has anyone come up with a solution?

i’ve seen some suggest using the discount shareable link and redirecting the user back to the home page after that, but I’m curious what the best approach is