Hi everyone. I’m currently use Dawn theme.
I have a bar in announcement-bar.liquid with a message, the message will update when something is added or removed from the cart.
I created this Javascript file
document.addEventListener('DOMContentLoaded', function () {
console.log("Hi! I'm here!!!");
function reloadAnnouncementBanner() {
//myCodeHere
});
}
}
document.addEventListener('cart.itemAdded', function (event) {
console.log("ITEM ADDED");
reloadAnnouncementBanner();
});
document.addEventListener('cart.itemRemoved', function (event) {
console.log("ITEM REMOVED");
reloadAnnouncementBanner();
});
});
From the log i can see the log in the document listner (the “Hi! I’m here” log), so i know i call the js file correctly, but there are no “ITEM ADDED” or “ITEM REMOVED” whenever i try to add or remove an item from the cart, so i think the listner on the cart doesn’t work.
Maybe someone has faced the same issue and has some answer, it’ll be very great!
Thank you very much