Categories
Woocommerce

How to add, remove or customize any link from My Account menu in woocommerce

When you install Woocommerce on your website, it will automatically create My Account page for you. If you visit the My Account Page, you will see a customer account related menu links in it. Check out the screenshot below :

Woocommerce My account Menu Links
Woocommerce My account Menu Links

Why change the My Account menu?

There are scenarios when you may not need some of the links or may want to customize them in the My Account page. Here are three example scenarios :

  • If you are selling physical products from your woocommerce based website, you may not need the Downloads URL.
  • If you are selling Digital Products, you may not need the Address URL from your My account menu.
  • You may want to rename the Dashboard text or add your own custom URL to the My account navigation.

How to remove URLs from My Account menu in woocommerce without code

From the woocommerce endpoints section, you can change the slug of the many customer-related pages under my account, like Orders page, View order, Downloads, Edit Account, Address, Payment Methods, Lost password and Log out. First visit the Woocommerce Endpoints settings, you have to visit WooCommerce >> Settings >> Advanced.

WooCommerce My Account Endpoint
WooCommerce My Account Endpoint

Then, scroll down to the Account endpoints section and there you can change many customer accounts related page slug. You can simply remove the slug of Downloads or Payment Methods or Addresses, Log out section and keep it blank to hide it from My Account navigation in the front end.

Here is a video explaining how you can use woocommerce endpoints to remove links from “My Account” menu

How to remove any link from My Account menu in woocommerce with code

You can easily customize the My Account menu items by using the woocommerce_account_menu_items filter. Here the code snippet is given below, which you can use to remove Dashboard URL, Orders URL, Downloads URL, Edit Account URL, Payment Methods URL, AddressURL or Log out URL from the My Account menu. Just comment out the one that you don’t want to hide with a double slash ( // ) at the beginning of the line.

/**
Snippet to remove any URL from My Account menu in woocommerce
Source : https://wpti.ps/?p=307
**/

add_filter ( 'woocommerce_account_menu_items', 'wptips_customize_account_menu_items' );
function wptips_customize_account_menu_items( $menu_items ){
 
	//unset( $menu_items['dashboard'] ); // Remove Dashboard from My Account Menu
	//unset( $menu_items['orders'] ); // Remove Orders from My Account Menu
	unset( $menu_items['downloads'] ); // Remove Downloads from My Account Menu
	//unset( $menu_items['edit-account'] ); // Remove Account details from My Account Menu
	unset( $menu_items['payment-methods'] ); // Remove Payment Methods from My Account Menu
	//unset( $menu_items['edit-address'] ); // Addresses from My Account Menu
	//unset( $menu_items['customer-logout'] ); // Remove Logout link from My Account Menu
return $menu_items;
 
}

How to change any menu item label from My Account Menu section

add_filter ( 'woocommerce_account_menu_items', 'wptips_customize_account_menu_items' );
 function wptips_customize_account_menu_items( $menu_items ){
 	
	// Chnage the Menu Item name text
	$menu_items['dashboard'] = 'My Account'; // Rename "Dasboard" in My Account menu to 'My Account'
	$menu_items['orders'] = 'My Orders'; // Rename 'Ordrers' to 'My Orders'
	$menu_items['edit-address'] = 'My Addresses'; //Rename 'Addresses' to 'My Addresses'

	return $menu_items;
}

How to add a custom URL to the My Account menu in any position

Add Custom URL in My Account menu in any position
// add custom endpoint for My Account menu
add_filter ( 'woocommerce_account_menu_items', 'wptips_customize_account_menu_items' );
function wptips_customize_account_menu_items( $menu_items ){
 	// Add new Custom URL in My Account Menu 
	$new_menu_item = array('contact-us'=>'Contact Us');  // Define a new array with cutom URL slug and menu label text
	$new_menu_item_position=2; // Define Position at which the New URL has to be inserted
	
	array_splice( $menu_items, ($new_menu_item_position-1), 0, $new_menu_item );
	return $menu_items;
}

// point the endpoint to a custom URL
add_filter( 'woocommerce_get_endpoint_url', 'wptips_custom_woo_endpoint', 10, 2 );
function wptips_custom_woo_endpoint( $url, $endpoint ){
 	if( $endpoint == 'contact-us' ) {
		$url = 'https://wpti.ps/contact-me/'; // Your custom URL to add to the My Account menu
	}
	return $url;
}

Reply here in the comment section with your questions if any.

By Murali Kumar

I am a Full Stack Web Developer with over 12 years of experience. I love WordPress & WooCommerce.

If you need help of a WordPress developer for your website, get in touch now!.

Follow me on Twitter : @geekz

Leave a Reply

Your email address will not be published. Required fields are marked *