Get cart subtotalAmount in theme app extension

Topic summary

Goal: Show a progress bar in a Theme App Extension based on cart subtotalAmount and reflect merchant-configured discounts from the app UI.

Latest guidance:

  • Retrieve cart data client-side via the /cart.js endpoint; it returns the subtotal in cents (subtotalAmount).
  • Fetch discount configurations from your app’s backend through an API endpoint; these values are managed by the merchant in your app’s UI.
  • Combine subtotalAmount and discount settings to compute/display current progress and applicable discount tiers in the Theme App Extension block.

Implementation notes:

  • Re-fetch data when the cart is updated to keep the progress and discounts accurate.
  • Secure requests between the Theme App Extension and your backend using OAuth tokens or signed requests.

Status: A practical approach is provided; no confirmation from the original poster on implementation or resolution.

Summarized with AI on December 20. AI used: gpt-5.

Hi guys,

I am building an app to apply discounts based on the cart subtotalAmount and I have two extensions:

  1. Theme App Extension to add an app block to the cart with a progressbar that shows how close you are to the next discount based on the current cart subtotalAmount.

  2. a discount function to get and config discounts

How can I get the value of the cart subtotalAmount in my Theme Extension App block and the configured discounts so when the merchant config the discounts in the app UI they show in the Theme App extension block ?

Hi jacobovelasquez,

You should be able to retrieve the cart data using an API call to /cart.js, which provides the subtotal amount in cents. Once you have the subtotal, you can fetch the discount configurations from your app’s backend via an API endpoint. These discounts are typically set up by the merchant in your app’s UI.

With both the subtotalAmount and discounts retrieved, you can dynamically render the applicable discounts in your Theme Extension block. To ensure the displayed information stays current, consider re-fetching data whenever the cart is updated and secure communication between the Theme Extension and your app backend using OAuth tokens or signed requests.