Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1188410
    fdcchief
    Participant

    Hi,
    I’m trying to do a couple of things here.

    1 – I want to remove the WooCommerce cart link on my main page – the link with # of items and price

    2 – On the Store page I have a second menu set using this function

    add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );
    
    function custom_blog_menu( $args ) {
      if ( x_is_shop() ) {
        $args['theme_location'] = 'primary';
        $args['menu'] = 'Store Menu';
      }
      return $args;
    }

    I’d like to use this menu on the Cart, My Account, and Checkout pages as well.

    One menu for the main site and a separate menu for all of the WooCommerce pages

    #1188412
    fdcchief
    Participant
    This reply has been marked as private.
    #1188708
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in!

    1] Since you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file.

    // Custom cart in the menu
    // =============================================================================
    function x_woocommerce_navbar_menu_item( $items, $args ) {
    
    	if ( X_WOOCOMMERCE_IS_ACTIVE && x_get_option( 'x_woocommerce_header_menu_enable' ) == '1' ) {
    	  if ( $args->theme_location == 'primary' && $args->menu == 'Store Menu' ) {
    	    $items .= '<li class="menu-item current-menu-parent x-menu-item x-menu-item-woocommerce">'
    	              . '<a href="' . x_get_cart_link() . '" class="x-btn-navbar-woocommerce">'
    	                . x_woocommerce_navbar_cart()
    	              . '</a>'
    	            . '</li>';
    	  }
    	}
    
    	return $items;
    
    }
    add_filter( 'wp_nav_menu_items', 'x_woocommerce_navbar_menu_item', 9999, 2 );
    // =============================================================================

    2] You need to update your code and make use of this one:

    // Custom menu in some other pages
    // =============================================================================
    add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );
    
    function custom_blog_menu( $args ) {
      if ( x_is_shop() || is_cart() || is_account_page() || is_checkout() ) {
        $args['theme_location'] = 'primary';
        $args['menu'] = 'Store Menu';
      }
      return $args;
    }
    // =============================================================================

    We would loved to know if this has work for you. Thank you.

    #1188734
    fdcchief
    Participant

    It worked great! Thank you

    #1188787
    Prasant Rai
    Moderator

    You are most welcome. 🙂

  • <script> jQuery(function($){ $("#no-reply-1188410 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>