Skip to main content

Hide the Sticky Cart Button on the Homepage

This article outlines how to hide the sticky cart button on the home page

Updated this week

In certain storefront layouts, you may choose to hide the sticky cart button on the homepage for a cleaner look or improved user experience. UpCart makes this easy to customize using a simple CSS and JavaScript snippet that conditionally removes the button.

Use the following steps to hide the sticky cart button specifically when customers are viewing your homepage.

Code Required

Javascript

Copy the below code and paste it into the following directory:
​UpCart > Cart Editor > Settings > Custom HTML > Scripts (Before Load)

<script>
var stickyCartButton = document.querySelector("#upCartStickyButton");

if(stickyCartButton &&
(document.location.pathname == "/" + Shopify.locale ||
document.location.pathname == "/"))
{
stickyCartButton.classList.add("hideStickyCartButton");
}
</script>

CSS

Copy the below code and paste it into the following directory:
​UpCart > Cart Editor > Settings > Custom CSS

.hideStickyCartButton
{
display: none !important;
}

Note

This customization does not function reliably with the Advanced Setting: Render Cart in Shadow DOM enabled.

Did this answer your question?