Only show cart when logged in

Hi - I am working with an allocation that is 100% reserved for club members, so it is misleading to have a cart in the header when visiting the site as a non-member. I only want the cart to show up once you have logged in. Has anyone done this yet?

Assuming you are hosting the entire site on WineDirect and not a separate CMS like Wordpress?

Probably the most straightforward way to achieve what you want is by using javascript. You could see what classes are injected into a page’s code by Wine Direct once a user is logged in, and stipulate that the cart classes only show up when those are visible.

For example, once a user logs in to Wine Direct the class .v65-logout appears on the page (this is the user’s logout link). You can pretty safely assume if that class is present, a user is logged in. You can set up your cart to only show when that class is present (set display: none if it’s not).

The only thing to really worry about is how this will affect users with screen readers (disabled).

1 Like

I’m here with bated breath…

This could be done the way @another_redesign suggested, or a more simplistic approach would be to use the don’t show if zero attribute

<v65:modalCart display="dontShowIfZero"></v65:modalCart>

This assumes the store is fully secured, and club members will only see a cart once they’ve added a product to their cart.


Thanks for the quick and intuitive insights. We will look into it!

1 Like

Quick question, doesn’t don’t show if zero also not display the cart in scenarios where the user is logged in, but hasn’t added anything? Because I interpreted the OP as wanting the cart to show to those logged in, regardless of whether product was added to the cart or not. (I know this is a use case that has come up for me before.)

Correct - dont show if zero will always hide the cart if it’s empty, logged in or not. Just an easier non JS solution to the presented problem

1 Like