[Flow theme] Find a way to open the cart drawer?

Hi !

I just add an Ajax “AddToCart” functionnality on my theme, but i can’t find a way to open the cart drawer after that.

The theme used is Flow.

Someone wan help me ? Thanks !

Hi @marki-digital In themes with an ajax cart when you enable the ajax cart settings then in most themes the cart drawer should automatically open once a product is added to the cart.

If not there may be a bug with your theme or it’s setup.

If you coded your own ajax solution off the top of my head I can’t recall if Flow-theme has an exposed function for opening the drawer.

But a lot of themes are incredibly arrogant like this with way to many anonymous functions or framework libraries ignoring the aftermarket utility merchants need.

So the easiest bandaid fix is to use javascript to literally trigger a click on any existing cart drawer button.

var cartDrawerButtonSelector = ".js-drawer-open-right-link";
var cartDrawerButton = document.querySelector(cartDrawerButtonSelector);
/* alternative that returns array of ALL matching elements so reference the first with [0]
var cartDrawerButton = document.getElementsByClassName('js-drawer-open-right-link')[0];
*/

cartDrawerButton.click();
1 Like

Thanks @PaulNewton

I was hoping there would be another solution, but it also works :slightly_smiling_face:

And my other problem is how to update everytime the content of the cart drawer ?

I succeed it with this :

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {
                    bubbles: true
                }));

But it’s working only once, after my first addTocart event with success.

Did you find the solution for it?