This topic has 12 replies, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #65357
     avaloncakes
    Participant

    So I have different primary menus for non-members and members… the search and cart icon show up in the primary for the non-members but do not some up in the members’s menu. It is a plugin via PMPro that allows me to make multiple menus for this.

    #65365
     sharmstr
    Moderator

    The Kleo logic behind the cart looks for the menu that you have set as your primary or top menu. Lets stick with primary in this case since that’s what youre after. Anyhoooo, I’m assuming you have the non-member set as your primary menu in Appearance > Menu. I’ll also assume that PMPro filters the menu to switch it out when someone is logged in. BUT as far as Kleo is concerned, non-members menu is still the primary menu…. because technically it is.

    So, if all of that is correct, then I’d say you’ll have to figure out how PMPro filters the menu and add the kleo magic to it.

    Here’s how Kleo does is

    COPY CODE
    
    /***************************************************
    :: Header menu cart
    ***************************************************/
    
    if ( sq_option( 'woo_cart_location', 'primary' ) != 'off' )
    {
    	add_filter( 'wp_nav_menu_items', 'kleo_woo_header_cart', 9, 2 );
    }
    
    if(!function_exists('kleo_woo_header_cart'))
    {
    	/**
    	 * Add search to menu
    	 * @param string $items
    	 * @param oject $args
    	 * @return string
    	 */
    	function kleo_woo_header_cart ( $items, $args )
    	{
    		$cart_location = sq_option( 'woo_cart_location', 'primary' );
    		
    	    if ( $args->theme_location == $cart_location )
    	    {
    	        $items .= kleo_woo_get_mini_cart();
    	    }
    	    return $items;
    	}
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #65372
     sharmstr
    Moderator

    Okay, I’ve been playing with this. But obviously cant test it. So, disable the cart in theme options. Then try this in your child’s functions.php file.

    COPY CODE
    
    add_filter( 'wp_nav_menu_items', 'add_cart_to_menu', 9, 2 );
    
    function add_cart_to_menu ( $items, $args )
    {
        if ( $args->theme_location != 'top' ) {
            $items .= kleo_woo_get_mini_cart();
        }
        return $items;
    }
    

    Again, I have no idea how pmpro is doing the menu switch so it may not work. But it does add the cart to my primary menu even with it disabled in Theme Options.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #65375
     avaloncakes
    Participant

    So that put an extra shopping cart on the “primary” (non-members menu) and put just the shopping cart on the members menu… no search bar.. but looks like we’re headed in the right direction 🙂

    #65378
     sharmstr
    Moderator

    It shouldnt put an extra one on the primary if you’ve disabled it in theme options. I’ve only given you the cart code so far.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #65380
     avaloncakes
    Participant

    Ah sorry missed that part! Works like a charm! Perfect! Is adding the search just as simple?

    #65386
     sharmstr
    Moderator

    I dont know. LOL. I’ll get back to you.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #65560
     sharmstr
    Moderator

    Basically the same code/concept. Turn off the search in Theme Options > Header, then add this code to your functions.php file.

    COPY CODE
    
    add_filter( 'wp_nav_menu_items', 'add_search_to_menu', 10, 2 );
    
    function add_search_to_menu(  $items, $args ) {
    
        if ( $args->theme_location != 'top' ) {
            $form = kleo_get_search_menu_item();
            $items .= '<li id="nav-menu-item-search" class="menu-item kleo-search-nav">' . $form . '</li>';
        }
        return $items;
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #66067
     avaloncakes
    Participant

    Great thank you so much!

    #66247
     avaloncakes
    Participant

    Worked perfectly! One last thing… is there anyway to turn it off on the top bar and only have it on the main menu?

    #66252
     sharmstr
    Moderator

    Its already coded to do that. Its not showing up on my top bar. That’s what the if ( $args->theme_location != ‘top’ ) { line does

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #66253
     avaloncakes
    Participant

    Ahh, it’s not showing up in my main top bar but it is showing up in my member’s top bar. I can work around that though! Thanks for all your help, very much appreciated!

    #66262
     sharmstr
    Moderator

    oohhhh. Got it. Lemme look into that. sorry

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 13 posts - 1 through 13 (of 13 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?