I'm trying to use BuyButton.js to access cart info from our Shopify store. I want to have a cart icon on our main site (www.autelrobotics.com) that pulls the number of items from the cart at shop.autelrobotics.com and updates when you add items from www. But the cart seems to be a separate instance from the cart in the storefront. If I add 3 items from www., then click through to shop., the cart is empty. If I go back to www. the 3 items are still there.
This is where I'm starting. (For now, just creating a cart object and accessing the number of items to display in the cart icon.)
Many thanks in advance.
My understanding now is that the Buy Button and Online Store are discrete sales channels that operate independently. So if a user interacts with our shop (loads up a cart) via the Buy Button, then visits the Online Store, the cart in the Online Store is empty.
That seems counterintuitive. Is there something fundamental I'm missing?
I just had the same problem when developing a remote front-end for a Shopify store. I spent a lot of time researching it and I could not find a way to persist the cart across the remote store to the Shopify side. What I ended up doing was creating a cart with the Shopify Buy API on my remote site, setting that up to function as normal with the exception that the add to cart action did not open the cart pop up, but rather linked the user to their cart on the Shopify site using the url post for the cart page:
So, each time a user adds an item on my remote store, it adds the item to the remote store cart, then pops them over to the cart page which, syncs the carts on the pages, with the new item.
Shopify really needs to work on this though. The API is a great idea but it is extremely limited in what it is capable of, especially when communicating with the online store. I don't understand why when we create a cart instance via the Buy SDK, it isn't stored somewhere that can be accessed by the Shopify store.
I understand that there could be potentially thousands of carts being stored per store, which is maybe why they don't do it, who knows. Seems counterintuitive though to tout that you can offload the front-end of your Shopify then not have this basic interaction possible.