[Resolved] Cart Menu Item Won't Display When Using Conditional Menu

Home Forums Support [Resolved] Cart Menu Item Won't Display When Using Conditional Menu

Home Forums Support Cart Menu Item Won't Display When Using Conditional Menu

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #521334
    Fahmi

    Hi.

    I am using Conditional Menu by Themify with GPP.

    I had 2 menu for Primary Menu NavBar.

    For WooCommerce page, I am using an alternative menu different from the home page menu.

    It seem that WooCommerce Cart Menu item won’t display on the alternative menu. But it will display just fine on the other one.

    Is there anything I can to to fixed this?

    #521706
    Leo
    Staff
    Customer Support

    Hi there,

    Have you checked with the plugin support for this issue?

    Can you link us to the site in question?

    You can edit the original topic and use the private URL field.

    #522133
    Fahmi

    I am sorry for my late reply.

    I have update my first post.

    The woocommerce shop section is still hidden with no link to shop section. You will have to type manually the url since I still not put the link menu to shop section.

    #522441
    Leo
    Staff
    Customer Support

    I’m not able to find the WooCommerce page? All the menu links on the home page are anchors.

    Let me know.

    #522496
    Fahmi

    I am sorry.

    I have update my web link to shop section.

    #522754
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    The WC menu item will only be added to the “primary” theme menu location.

    You can adjust it like this:

    add_filter( 'generate_woocommerce_menu_item_location', 'tu_conditional_wc_menu_item' );
    function tu_conditional_wc_menu_item() {
        return array(
            'primary',
            'another-location',
            'one-more',
        );
    }

    Hope this helps ๐Ÿ™‚

    #522785
    Fahmi

    Hi Tom, thank you for your time.

    I have been tinkering with the code for some time.
    But it does not help.

    add_filter( 'generate_woocommerce_menu_item_location', 'tu_conditional_wc_menu_item' );
    function tu_conditional_wc_menu_item() {
        return array(
            'primary',
            'secondary'
        );
    }

    When I try using the code above, WooCommerce Cart Menu item is not display at all.
    So I have removed the the code.

    I had 2 menu which is ‘Home Menu’ & ‘Shop Menu’.

    ‘Home Menu’ is set to primany menu location by default.
    ‘Shop Menu’ is an alternative menu that will only be displayed on WooCommerce related page.

    ‘Shop Menu’ does not have location.

    But base on the condition set, Conditional Menu plugin will replace the whole ‘Home Menu’ itself with ‘Shop Menu’.

    As right now, WooCommerce Cart Menu will be display on all page that use ‘Home Menu’ but will not display on WooCommerce related page which right now use ‘Shop Menu’.

    I guest it’s not working because of how the plugin work.

    For now I will try to look for other way to do this.

    Thank you again for your time.

    #523355
    Tom
    Lead Developer
    Lead Developer

    Ah, my mistake – there can only be one value.

    You can add the item to all menus like this:

    add_filter( 'wp_nav_menu_items', 'tu_wc_menu_cart', 10, 2 );
    function tu_wc_menu_cart( $nav, $args ) {
    	// If our primary menu is set, add the search icon
    	if ( function_exists( 'generatepress_wc_cart_link' ) && function_exists( 'is_cart' ) ) {
    		return sprintf(
    			'%1$s
    			<li class="wc-menu-item %4$s" title="%2$s">
    				%3$s
    			</li>',
    			$nav,
    			esc_attr__( 'View your shopping cart','generate-woocommerce' ),
    			generatepress_wc_cart_link(),
    			is_cart() ? 'current-menu-item' : ''
    		);
    	}
    	
            return $nav;
    }
    #523436
    Fahmi

    WooCommerce Cart Menu item is now display on Primary Menu even after it being replace when by conditional menu plugin.

    First we need to untick Display cart in menu option from theme customizer Appearance > Customize > Layout > WooCommerce. If not then we would have 2 WooCommerce Cart Menu item on Primary Menu.

    After that it all working fine.

    Thank you Tom.

    #523817
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #739257
    Tully

    Hi guys, I am wanting to do the same thing. Where do I add this code?

    Thanks, Tully

    #739550
    David
    Staff
    Customer Support

    Hi there,

    the code is PHP, this article covers the methods of adding:

    https://docs.generatepress.com/article/adding-php/

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.