Does anyone know of a way to have the cart drawer open automatically once an item is added to the cart? I am using the Kingdom them, but it doesn’t seem to be an automatic option. My site URL is hoekhome.com if that helps anyone to understand the predicament.
Thanks in advance,
Evan
1 Like
Hi Evpreuss,
my solution was to add in js an event that reads the change in the quantity of products and then adds the “opened” class to the cart sidebar.
//set the variable with the current quantity in the cart
var cart_count = Number( document.querySelector("span.count").innerHTML );
//I add the html event of change
document.querySelector("span.count").addEventListener("DOMSubtreeModified", function() {
//if there are more first products I apply the class
if(cart_count < Number( document.querySelector("span.count").innerHTML ) ){
document.querySelector(".sidebar__cart").classList.add("opened");
}
//then I update the variable
cart_count = Number( document.querySelector("span.count").innerHTML );
});
if it doesn’t work try wrapping it in a setTimeout (() => {// code}, 1000);