Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Need menu item only if cart has item(s)

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › Need menu item only if cart has item(s)

Tagged: menu item

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 3 months ago by dwest100.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 14, 2015 at 7:04 am #12211
    dwest100
    Member

    Hi,

    I have a WordPress plugin that allows me to add conditional filters to any menu item. I just need to know what filter I could add to it that would indicate the cart has items in it or is empty.

    Plugin author’s example of adding a new conditional statement for displaying/hiding a menu item when current page is a custom-post-type:

    // theme's functions.php or plugin file

    add_filter( 'if_menu_conditions', 'my_new_menu_conditions' );

    function my_new_menu_conditions( $conditions ) {

    $conditions[] = array(

    'name' => 'If single custom-post-type', // name of the condition

    'condition' => function($item) { // callback - must return TRUE or FALSE

    return is_singular( 'my-custom-post-type' );

    }

    );

    return $conditions;

    }

    How could that code be modified to display/hide a menu item when the cart has items and hide it when it is empty?

    Thanks much!

    February 14, 2015 at 4:00 pm #68592
    wzp
    Moderator

    You can use the eStore_get_total_cart_item_qty() PHP function to return the number of items in the cart. If the return value is > 0 it means there are items in the cart.

    February 16, 2015 at 3:50 am #68593
    dwest100
    Member

    Thanks! I was able to make it work with that tidbit of information :-)

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ