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
Issue: Users want the cart drawer to automatically slide open when an item is added to cart in Shopifyâs Pipeline theme, rather than redirecting to a separate cart page.
Initial Suggestion: GemPages support recommended using the themeâs built-in customize settings (Online Store â Theme â Customize â Cart settings), but this only opens a new page, not the drawer.
Working Solution (JAFC):
theme.css to hide the default product add popdown:.product-add-popdown { display: none !important; }
theme.js to trigger cart drawer opening:document.addEventListener('theme:cart:popdown', function(e) {
document.querySelector('[data-drawer="cart-drawer"]').dispatchEvent(new CustomEvent('theme:drawer:open', { bubbles: false }));
});
Status: Solution confirmed working by at least one user (ShroomSmoothie). However, another user (Mudassir11) reported it didnât work for their site (slioailet.com), and a user with the Minimog theme also requested help, suggesting the solution may be Pipeline-specific.
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
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:
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-cart-in/td-p/1425755
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 %}
{% endif %}
{% if current_variant.available %}
{% endif %}
hope this helps!
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
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.
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/
can you also help me? we are using minimog theme