Ready to get started?Download WordPress


Menu Item Visibility Control
Something in cart? (2 posts)

  1. EzRiIgK
    Posted 10 months 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 10 months 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.


You must log in to post.

About this Plugin

About this Topic