Shopify / buy-button-js

BuyButton.js is a highly customizable UI library for adding ecommerce functionality to any website.
http://shopify.github.io/buy-button-js/
MIT License
242 stars 114 forks source link

Buy buttons not showing on chrome mobile #372

Closed AbrahamBrookes closed 7 years ago

AbrahamBrookes commented 7 years ago

I have implemented some shopify buy buttons on my site and they are working fine in all browsers except Chrome. In Chrome mobile my buttons don't appear at all. Chrome on a desktop displays the buttons fine but if I go into developer mode and turn on responsive viewports and refresh the page then I get an error in my console:

TypeError: Failed to execute 'fetch' on 'Window': Invalid value
    at n.y [as ajax] (buy-button-storefront.min.js:2)
    at n.fetchSingle (buy-button-storefront.min.js:3)
    at n.fetch (buy-button-storefront.min.js:3)
    at n [as fetchProduct] (buy-button-storefront.min.js:2)
    at e.sdkFetch (buy-button-storefront.min.js:6)
    at e.fetchData (buy-button-storefront.min.js:6)
    at e.t.setupModel (buy-button-storefront.min.js:6)
    at e.setupModel (buy-button-storefront.min.js:6)
    at buy-button-storefront.min.js:6
(anonymous) @ buy-button-storefront.min.js:7
notify.bugsnag.com/js?notifierVersion=2.5.0&apiKey=984b96f9e4731b19d6ef0374…on-storefront.min.js%3A6%3A5401&payloadVersion=2&ct=img&cb=1490612759503:1 GET https://notify.bugsnag.com/js?notifierVersion=2.5.0&apiKey=984b96f9e4731b19…tton-storefront.min.js%3A6%3A5401&payloadVersion=2&ct=img&cb=1490612759503 net::ERR_BLOCKED_BY_CLIENT
v.shopify.com/buy_now/track?event=Viewed%20Product&addClass=function%20(cla…5CC-443D-9B3D&microSessionCount=2&firstSeen=2017-03-27T10%3A44%3A57.475Z:1 GET https://v.shopify.com/buy_now/track?event=Viewed%20Product&addClass=functio…-75CC-443D-9B3D&microSessionCount=2&firstSeen=2017-03-27T10%3A44%3A57.475Z net::ERR_BLOCKED_BY_CLIENT`
michenly commented 7 years ago

can you provided the url to the buy button for debugging purpose?

AbrahamBrookes commented 7 years ago

Sure, www.redlamp.com.au/myriad/shopify2.html

On 28 Mar 2017 4:06 AM, "Michelle Chen" notifications@github.com wrote:

can you provided the url to the buy button for debugging purpose?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Shopify/buy-button-js/issues/372#issuecomment-289535827, or mute the thread https://github.com/notifications/unsubscribe-auth/AH9FKKmFAidqdm-eEy2y_EwK7pKisKsPks5rp_rCgaJpZM4MqHta .

AbrahamBrookes commented 7 years ago

I found the culprit - I had extended the Object with my own rudimentary add/remove class functions. Removing the following code fixed the problem:

Object.prototype.addClass = function(clas) {        

    if (this.classList)
        this.classList.add(clas);
    else
        this.className += ' ' + clas;

}

Object.prototype.remClass = function(clas) {        

    if (this.classList)
        this.classList.remove(clas);
    else
        return;
}

Thanks!