Viewing 3 replies - 1 through 3 (of 3 total)
  • just leave out the “if” and

    global $woocommerce; return ( $woocommerce->cart->cart_contents_count!==0 );

    or “==0” depending on how you want it to work. So long as your Widget Logic code returns true, the widget will appear. Two notes:

    1) i added a $ in the global
    2) i’m not entirely sure you can do $object->propertyX->propertyY directly.

    Thread Starter jimlongo

    (@jimlongo)

    Thanks alanft.

    If I echo
    global $woocommerce; var_dump ( $woocommerce->cart->cart_contents_count);

    it returns int(1) or more when there is something in the cart and int(0) when the cart is empty.

    However the statement you gave me always shows the menu, whether the cart has contents or not. I’ve tried >0 as well.

    Thread Starter jimlongo

    (@jimlongo)

    I must apologize, I just remembered that the only reason I asked this question was to understand “Widget Logic” , and I believe you have explained it to me. I’m not using your plugin at the moment.

    I’m actually using this logic in another plugin that claims It works like ‘Widget Logic’ but for menu items..

    Now that I understand the logic expression I’ll go bother that author.

    Thanks again.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘IF logic with Widget Logic’ is closed to new replies.