New Shopify Certification now available: Liquid Storefronts for Theme Developers

Auto close "added to cart" popup

New Member
7 0 0

HI there, does somebody know how I can edit the code of my theme so that the "added to cart" popup that appears after you add something to your cart closes automatically after 3 seconds?


I'm using the Empire theme 

My Store URL: 

Password: 16012006


The popup in question: 

Bildschirmfoto 2023-08-27 um 10.38.38.png


Thanks in advance for any help


Replies 2 (2)
Shopify Expert
2942 394 414

Hi @JonasZitzer ,


To set a timer to remove the mini cart, you could follow the steps below:

Open Your theme, select Your current theme => Edit code, and then open file theme.liquid.

Add this code at the end of this file:

const targetElement = document.querySelector('');

const observer = new MutationObserver((mutationsList, observer) => {
  for (const mutation of mutationsList) {
    if (mutation.type === 'childList') {
      if (mutation.addedNodes.length) {
        let mini_cart = document.querySelector(".atc-banner--container");
        if (mini_cart) {
          setTimeout(() => {
          }, 3000);

const config = { childList: true, subtree: true };

observer.observe(targetElement, config);

I have tested your theme, and everything works well.

I hope this comment will assist you in solving the problem. @JonasZitzer 


If our suggestions are useful, please let us know by giving it a like or marking it as a solution.

For B2B solutions and custom pricing, check out B2B Solution & Custom Pricing |
For adding product labels/badges, visit Product Labels by BSS

BSS Commerce - Shopify Apps & Store Development Service Provider

Hire a Shopify expert | Shopify Plus Store Development

New Member
7 0 0

Hi there, thanks for your effort, 🙂 I tested it but when I add another Product it does not add the Product. I don't want to hide the element completely, but rather just close it so that when you add another product it appears again.