Liquid, JavaScript, themes, sales channels
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 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
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.
User | RANK |
---|---|
38 | |
24 | |
13 | |
11 | |
8 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023