Shopify themes, liquid, logos, and UX
Has anyone got the code snippet to automatically open the cart drawer when an item is added to cart in the Pipeline theme?
Thanks in advance
Solved! Go to the solution
This is an accepted solution.
1. Add this snippet to end of theme.css
/* CSS - Hide the product add popdown */
.product-add-popdown{
display: none !important;
}
/* end */
2. Add this snippet to end of theme.js
/* Javascript - Show cart drawer when product added to cart */
document.addEventListener('theme:cart:popdown', (e) => {
const listener = (e) => {
document.querySelector('[data-drawer="drawer-cart"]').dispatchEvent(
new CustomEvent('theme:drawer:open', {
bubbles: false,
})
);
document.removeEventListener('theme:cart:change', listener);
};
document.addEventListener('theme:cart:change', listener);
});
/* end */
Hello @JAFC
It's GemPages support team and glad to support you today.
This is a feature of the theme, set in customize
I would like to give you a solution to support you:
1. Go to Online Store -> Theme -> Customize:
2. Goto settings -> cart
3. Select Cart drawer and save
Hope my solution can work and support you!
Kind & Best regards!
GemPages Support Team.
Hi @GemPages
This option leads to a whole new page opening up. I would like the cart draw to slide our automatically when an item is added to cart.
This issue was raised by another user in this post but no solution was provided: https://community.shopify.com/c/shopify-design/automatically-open-cart-drawer-when-item-added-to-car...
Please see the screenshots in this post for reference.
Thanks again!
Hello there
To automatically open the cart drawer when an item is added to the cart in a Shopify store using the Pipeline theme, follow these steps:
In the Shopify admin, go to the "Online Store" section and click on "Themes."
Find the Pipeline theme and click on the "Actions" dropdown, then select "Edit code."
In the "Sections" directory, find the "cart-template.liquid" file and click on it to open it for editing.
Find the line of code that adds an item to the cart, which should look something like this:
{% if current_variant.available %}
<form action="/cart/add" method="post" enctype="multipart/form-data">
{% include 'add-to-cart-form' %}
</form>
{% endif %}
{% if current_variant.available %}
<div id="add-to-cart-form">
<form action="/cart/add" method="post" enctype="multipart/form-data" onSubmit="Shopify.AjaxCart.toggle()">
{% include 'add-to-cart-form' %}
</form>
</div>
{% endif %}
hope this helps!
If this fixed your issue, likes and accepting as a solution are highly appreciated
| Build an online presence with our custom-built Shopify Theme: EcomifyTheme
| Check out our reviews: Trustpilot Reviews
| We are Shopify Partners: EcomGraduates Shopify Partner
Hi @EcomGraduates thanks for your response. I checked the cart-template.liquid and that line of code doesn't appear to exist. We're using Pipeline version 6.2.2 and the site is dormusleep.com if that helps.
Thanks again
Hi,
i hope you are doing well its not working and not trigging my drawer please can you give me solution?
My website https://www.teliaoils.com/
This is an accepted solution.
1. Add this snippet to end of theme.css
/* CSS - Hide the product add popdown */
.product-add-popdown{
display: none !important;
}
/* end */
2. Add this snippet to end of theme.js
/* Javascript - Show cart drawer when product added to cart */
document.addEventListener('theme:cart:popdown', (e) => {
const listener = (e) => {
document.querySelector('[data-drawer="drawer-cart"]').dispatchEvent(
new CustomEvent('theme:drawer:open', {
bubbles: false,
})
);
document.removeEventListener('theme:cart:change', listener);
};
document.addEventListener('theme:cart:change', listener);
});
/* end */
Hey JAFC - I can't thank you enough for this....
THANK YOU THANK YOU THANK YOU!!
Seriously... thank you!
May the rest of your life be filled with positive blessings and good karma.
can you also help me? we are using minimog theme
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024