Completely Hide Cart if Empty

Hi
I am trying to completely hide the cart if the count is zero. I’ve managed to hide the count number but not the entire cart using dynamic content.


Please can you advise.
Thanks

Hello @tapper65,

Thank you for the inquiry.

Which dynamic content did you use? Have you tried creating a condition based on the value of {{woocommerce.cart_items}} ?

Please provide the login details in the secure note so we can access the builder.

Best regards,
Ismael

Yes I have tried that - it only hides the cart count as mentioned above. Login details in secure note
Thanks

Hello @tapper65,

I would suggest you please set the conditions on the cart total element like this. “{{dc:woocommerce:cart_items}} != 0

Hope it helps
Thanks

Hi if you look at the Jla_Site_2025 header I can not seem to add the “!=” in your screen shot.
What I now have does hide the cart, but when I add a product to the basket it all stays hidden.
What do you suggest?
Thanks

We switched the condition from String to Number and used the value {{dc:woocommerce:cart_items_raw}} is > 0 . Please note that this condition will be enforced on page load or once the document is rendered. If the item count is 0 on page load, the cart will not display even if you add something to it. It will only display again if you refresh the page and the total number of items in the cart is greater than zero.

Hey @tapper65,

To use the "!=", you used a Number instead of a String.

Hope that helps.

Hi Ok that is looking good but we have now lost the cart item count.
How can we add that back?
Thanks

Hey @tapper65,

To show the count number, I added this dynamic code {{dc:woocommerce:cart_items_raw}}.

Hope that helps.

Hi thanks for the reply.
The cart now shows even when the count is zero. The cart seems to hide on the shop page but not elsewhere when count is zero.
To clarify the client would like:
a) no cart on the homepage
b) cart to show everywhere else only if the count is 1 or higher.
I tried to modify your code with a condition “when front page is not being viewed” but it didn’t work.
Please advise.
Thanks

Hi @tapper65,

I have checked and found that the condition is added correctly and the headers are also assigned to respective pages. I found the Cart icon in the News page only, that seems there might be some cache that is the reason behind your problem. I would suggest you check once by clearing all types of cache including the Server Level cache and, System Cache from Cornerstone > Settings > System > Clear System Cache and check in the incognito/private mode of the browser.

Hope it helps.
Thanks

Hi that looks good to me.
I’ll open this ticket again if needed.
Many thanks for your help.

Glad we could help! Feel free to update us if you need anything else. Have a nice day.