EvgeniyMukhamedjanov / liquid-ajax-cart

Build a Shopify Ajax-cart without JavaScript coding
https://liquid-ajax-cart.js.org
194 stars 22 forks source link

Ajaxified cart doesn't seem to work when console/inspector is open #70

Closed indextwo closed 1 year ago

indextwo commented 1 year ago

I'm a Shopify dev creating a new theme from scratch (so there's no existing JS interfering with cart functions), but I was initially baffled when I first implemented this and it didn't seem to work. It would send an XHR request that showed up in the console, and the classes would be added/removed on the body, but then the actual cart quantities wouldn't update.

It wasn't until I tested this on one of the sites listed on the project homepage using liquid-ajax-cart that I saw the same behaviour (I'd glanced at it earlier and it seemed to work just fine) - then I put 2 & 2 together: with the console/developer panel open, the ajaxified cart doesn't work. Close the panel, it works fine. I've tested this in FF 115 & Chrome 114 - same behaviour on both.

To replicate

  1. Go to https://twoislandsco.com/ (one of the sites listed as using liquid-ajax-cart)
  2. Add something to the cart, then from the minicart click on View my cart in the top left
  3. On the main cart page, open up your dev panel (F12 on PC) and then try changing the quantity. Nothing happens.
  4. Close the dev panel and try again (no need to refresh) - works fine.

Note: I've tried this on at least 3 other stores listed in the Built with Liquid Ajax Cart and they all show the same behaviour.

This is a minor issue, as I don't imagine most people are browsing the web with the console open, but definitely seems odd.

EvgeniyMukhamedjanov commented 1 year ago

Hi @indextwo , it might happen because of the https://liquid-ajax-cart.js.org/reference/updateOnWindowFocus/ parameter. When your focus is in the console and if you go back to the page -- Liquid Ajax Cart will run a request just to update the cart. Just set this option to false when you are developing.

indextwo commented 1 year ago

@EvgeniyMukhamedjanov Thanks for this - I missed that reference page, so that's super-handy to have.

As it happens, I think this may have been some Shopify weirdness 🥴 I asked a friend to check it for me on their computer. As I was recreating the steps (on one of those showcase stores), I noticed it suddenly wasn't happening any more. Went back and checked the 3 sites where I was able to recreate the problem, and now it seems to be fine?

Shopify wasn't letting anyone log in earlier this morning, so I'm just going to assume it was Shopify having a rough morning and leave it at that 😬

EvgeniyMukhamedjanov commented 1 year ago

Yeah, Shopify is so... Shopify :-)