Access checkout object through JavaScript

Topic summary

Main issue: An app developer needs to read checkout line items via JavaScript on the Shopify checkout page but finds the global object Shopify.checkout is present in some stores and missing in others.

Key details:

  • In stores where it works, the checkout HTML includes a script defining Shopify.checkout = { … }.
  • In other stores, that snippet is absent, so the object is undefined. The developer cannot use Liquid (e.g., {% checkout %}) or modify templates.
  • Goal: Determine where the snippet originates and how to ensure it’s available consistently to retrieve line items client-side.

Constraints/clarifications:

  • Editing checkout.liquid is only available on Shopify Plus plans, as noted by a respondent.
  • The app developer cannot modify merchants’ Liquid; they rely on injected JavaScript after the checkout loads.

Open questions / status:

  • Origin of the Shopify.checkout snippet and a method to force its inclusion remain unanswered.
  • Another participant asked if a solution was found, indicating no confirmed resolution yet.

Notes:

  • “Shopify.checkout” is a JavaScript object exposing checkout data (e.g., line items = products in the order). The thread offers no workaround or definitive guidance.
Summarized with AI on February 13. AI used: gpt-5.

I see that in certain stores I can access the checkout object through the Shopify.checkout variable but in other stores this variable is not defined.

In the stores where the checkout object is defined, the checkout HTML page contains this snippet:

<script>Shopify.checkout = { ... }</script>

However this snippet is not included in the others.

Where that snippet come from? How can I force it to be included in the stores where is not available?

Basically I need to get the line items of the checkout from a script we inject in our client’s checkout page. I can’t modify the liquid templates so using {% checkout … %} is not a solution.

@dropy

Can you please confirm, In which with file you want to add this code? Are you taking about checkout.liquid file?

Also confirm which Shopify plan you have? because, you can edit the checkout.liquid only for Shopify Plus plan.

Thank you,

Tejas

I’m the developer of an app, not a merchant. My app needs to get the line item objects when the checkout page is shown, but the Shopify.checkout object is not always available in all stores my app is installed in.

I can’t modify my client’s the liquid templates, I need to get the line item objects through JavaScript once the checkout page is loaded.

Thanks

Did you find any solution?.