Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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: https://gokiwii.de
Password: 16012006
The popup in question:
Thanks in advance for any help
🤝
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:
<script> const targetElement = document.querySelector('.site-header.site-header-nav--open'); 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(() => { mini_cart.remove(); }, 3000); } } } } }); const config = { childList: true, subtree: true }; observer.observe(targetElement, config); </script>
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, marking it as a solution, or donating here ☕.
B2B Solution & Custom Pricing | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
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.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025