"TypeError: Cannot read properties of undefined (reading 'indexOf')" Buy Button error

"TypeError: Cannot read properties of undefined (reading 'indexOf')" Buy Button error

truestory
Visitor
1 0 1

I'm getting the following error in my Javascript console and my Buy Button is not rendering on the web page as a result:

TypeError: Cannot read properties of undefined (reading 'indexOf') 
at buy-button-storefront.min.js:10:5524

 

This looks like an issue w/ Shopify's code, correct? Have they made breaking changes to the API in the last year? The embed code for this button is a couple of years old.

 

What's strange is that the Buy Button that generated this code has disappeared from my Shopify Settings, so I'll need to create a new one. How could it disappear like that?

Reply 1 (1)

nireno
Shopify Partner
2 0 1

I had a similar issue and was able to resolve it by upgrading the version of buybutton from 1.0.0 to 2.4.0

Previously: "https://sdks.shopifycdn.com/buy-button/1.0.0/buybutton.min.js"
Now: "https://sdks.shopifycdn.com/buy-button/2.4.0/buybutton.min.js"

 

Maybe the docs need updating because it's forever referencing the 1.0.0 build.