Shopify themes, liquid, logos, and UX
I'm trying to hide the cart icon when the cart is empty, but have it show when there are items in the cart. I've added this to theme.liquid at the end before </body>:
<style>
#cart-icon-bubble{
{%- if cart.item_count != 0 -%}
display: none !important;
{%- endif -%}
}
</style>
It hides the cart button, but stays hidden and doesn't show when there are items in the cart. What am I missing here?
Solved! Go to the solution
This is an accepted solution.
Use this code
<style>
#cart-icon-bubble {
{% if cart.item_count == 0 %}
display: none !important;
{% endif %}
}
</style>
This is an accepted solution.
Use this code
<style>
#cart-icon-bubble {
{% if cart.item_count == 0 %}
display: none !important;
{% endif %}
}
</style>
Thanks a lot! This code worked perfectly.
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025