Support » Fixing WordPress » Woocommerce – Hide cart on certain conditions

  • Hello,

    I turned on the woocommerce plugin and I don’t find any settings related to the cart which is displayed automatically on my navigation menu.

    I have a specific section on my website where I would like to hide it, cause that’s not relevant.

    Basically, I need to hide it when users are logged in as employer (A role I’ve created) so I was thinking about adding some code in functions.php file with conditionals tags.

    But I don’t find anything about how to do it with this cart icon…

    Any idea ?


    • This topic was modified 11 months, 2 weeks ago by  jujukp.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @jujukp,

    If you are trying to hide cart icon on specific page, then simply add following css.


    Another method if user is not logged in(functions.php):

    <?php if (is_user_logged_in()): ?>

    Cart Code Goes Here

    <?php endif; ?>

    OR you can read this documentation:


    Hello @pradeepphule,

    Thanks for your help !

    The first method is working but I have some ads page generated automatically and I can’t update my CSS each time I have a new page.

    I’m trying to follow the second solution, which fits perfectly with what I need.
    The problem is that I don’t know which code refers to the cart icon…

    If you have any idea…

    Thanks a lot.

    • This reply was modified 11 months, 2 weeks ago by  jujukp.

    Hello @jujukp,


    Also I’m not a proficient in coding.

    I will give you another solution.

    When user logged in, one additional body class added in WordPress theme.
    e.g. logged-in

    Please refer this link:

    And when user logged out, this class automatically removes from the body class.

    Bi-default you can hide cart icon. And when user logged in you can follow this css rule.


    display:block !important;


    Hope this will works!


    Hi @pradeepphule,

    I need to produce the opposite effect:
    – Users logged in as recruiters = no cart
    – Users logged out or logged in with an other role = cart

    I set up your idea and it’s the best compromise I found until now:
    – The cart isn’t display for recruiters (and for any other user logged in, which is a minor problem for me).
    – The cart is display for logged out users.

    Thank you very much. I will keep this solution for the time being 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce – Hide cart on certain conditions’ is closed to new replies.