Re: Undefined Shopify.checkout variable

Why is the window.Shopify.checkout object undefined for some orders?

Sherki
Shopify Partner
12 0 3

Hello,
I have a script running that depends on the "window.Shopify.checkout" object in Thank-You page.
But the object is rather unreliable, and is undefined for certain orders.
I noticed the object present for roughly 50% of the orders of a Particular store and the object was undefied for the other 50%

 

Any leads in addressing the issue will be of great help.

Replies 3 (3)

Rishihuptech
Shopify Partner
643 118 129

Hi @Sherki 
The Shopify.checkout variable is not defined on all Shopify storefronts. It is defined on storefronts that are using the latest version of the Shopify checkout API. If you are seeing the error it means that the Shopify.checkout variable is undefined on your storefront. This can happen for a few reasons:

  • You are not using the latest version of the Shopify checkout API
  • You are not on a Shopify Plus account
  • You are not on a storefront that has enabled the Shopify checkout API
    • If you are not on a storefront that has enabled the Shopify checkout API, you will need to contact Shopify support to enable it for your storefront.
If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
Sherki
Shopify Partner
12 0 3

@Rishihuptech 
Thanks for the reply.
I am sure the Store is on Shopify Plus Plan.
As i mentioned, I'm able to access the checkout variable from dev console on thank-you page.
{window.Shopify.checkout} for few orders. While same is undefined for other orders of the same store.

logangelzer
Shopify Partner
21 5 9

@Sherki you may need to add a delay or event listener for DOMContentLoaded so that the page has enough time to fully load the data including this window variable so the value is not undefined.

Logan Gelzer
Founder & CEO
Logo Media
logan@logo.media