Themes & Pluginsweb developmentWordPress

How to custom Woocommerce Menu Items in My Account Page

Woocommerce is a very popular eCommerce Plugin. Which plugin used developer for make Product store or website. in many website used woocommerce plugin with their default options.

But now-a-days we can customize everything of woocommrce plugin and their options functions.

Now I will show now How to custom woocommerce menu items in my account page.

When I faced with My Account menu first time, my client asked me to add a custom link to it. I was surprised that this task was not so simple as it sounds.

Probably, it is the most easiest part of this tutorial. For example let’s imagine that our e-commerce shop doesn’t sell physical goods – and in that case maybe we do not need Addresses section (yes, I know that Billing Address details are also there, but we’re just learning now). Or maybe you want to remove Downloads from WooCommerce my account menu. Both are possible.

How to custom woocommerce menu items in my account page:: Step 1

Open your website wordpress dashboard and go to the menu item ‘theme editor’ under the “Appearance”.

open the functions.php file.

function wpb_woo_my_account_order() {
	$myorder = array(
		'dashboard'          => __( 'Dashboard', 'woocommerce' ),
		'orders'             => __( 'Orders', 'woocommerce' ),
		'downloads'          => __( 'Downloads', 'woocommerce' ),
		'sale-your-services' => __( 'Sale Your Services', 'woocommerce' ),
		'settings'			 => __( 'Settings', 'woocommerce' ),
        'how-can-refer' 	 => __( 'How can Refer', 'woocommerce' ),
		'edit-account'       => __( 'Change My Details', 'woocommerce' ),
		'my-reviews'         => __( 'My Reviews', 'woocommerce' ),
		'edit-address'       => __( 'Addresses', 'woocommerce' ),
		'payment-methods'    => __( 'Payment Methods', 'woocommerce' ),
		'../information'     => __( 'Information', 'woocommerce' ),
		'customer-logout'    => __( 'Logout', 'woocommerce' ),
	);
	return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );

Copy this codes and Past in the bottom of your functions.php file. I hope you know where to insert all the code from this post, if not – to functions.php. The result:

How to custom woocommerce menu items in my account page:: Step 2

then save the functions.php file and open your woocommerce myaccount page as like a customer. your website name slash myaccount

like https://webcource.com/myaccount/

you will see the menu items changed

 

It was simple enough, but we have not finished yet, if you go to /my-account/edit-address/directly, it will show you Addresses page. This should not happen, should it?

The first thought that came to my mind was to remove endpoints somehow. Dealing with $wp_rewrite or something like that. Please do not!

The above code is good. But when you want to remove both the menu item and its page as well, you do not need any coding. You can find all the default My Account subpages in WooCommerce > Settings > Account. All you need is just to set a specific endpoint empty.

Thank you for reading! Subscribe below if you want to receive new awesome WordPress and WooCommerce-related content once a week. Or leave a comment if you still have unanswered questions.

Tags

Related Articles

Leave a Reply

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

Close