Menu Item Visibility Control
[closed] Something in cart? (4 posts)

  1. EzRiIgK
    Posted 3 years ago #


    Not really fimiliar with codex. So was hoping someone who is could give me what i need.
    Want to show my "view cart" and "Checkout" menu items only if something has been added to the cart.
    Don't know if site url is needed but its: FJsHandbags.com

    Thanks Erik


  2. jimlongo
    Posted 3 years ago #

    That's funny, I was trying to do exactly the same thing.
    First I tried is_cart()
    But that only makes the cart and checkout menus visible if you are on the cart page.
    Otherwise they go away again . . . that's not the desired functionality i'm looking for.

    Since the plugin says it's like Widget Logic only for menus, I asked the Widget Logic author to confirm my logic is correct.

    If I echo
    global $woocommerce; var_dump($woocommerce->cart->cart_contents_count); it returns int(0) if the cart is empty and an integer greater than 0 if it has contents.

    So my "widget logic" is
    global $woocommerce; return ( $woocommerce->cart->cart_contents_count > 0);

    Logically this should show the Cart and Checkout menu items only if the cart has contents, however the menus display whether the cart has contents or not. Also tried !==0 with the same results.

  3. DatagoniaWeb
    Posted 2 years ago #

    I, too, would like to see an answer to this.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else's topic.

    I am now closing this 11 month old topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Menu Item Visibility Control
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic