Customize My Account Labels in WooCommerce

A request that we often get from our customers and on woocommerce shop owners is 'how do I customize the labels of the My Account page in WooCommerce?'.

The answer is not far away, because WooCommerce has everywhere "hooks & filters". These are connection points for your own customized functions without changing the core code. Developers always use that to develop custom functionality in WordPress and WooCommerce.

Briefly explain what a "hook" is and what a "filter" is:

  • Hook: this is the connection point for functions to work at a certain time and certain location (eg price calculator show at a curtain fabric product page).
  • Filter: this is a connection point to manipulate a variable to something else (eg a product price).

Now that you know a bit about hooks and filters, we will look at how we can apply this to the My Account page in woocommerce.

// Rename labels in My Account
add_filter ( 'woocommerce_account_menu_items', 'rms_woo_my_account_order' );
function rms_woo_my_account_order() {
$myorder = array(
'dashboard' => __( 'Mijn Profiel', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'edit-address' => __( 'Mijn Adres', 'woocommerce' ),
//'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $myorder;
}

What we have done above is to use an existing filter from WooCommerce: woocommerce_account_menu_items.
With this we can adjust the labels of the My Account 'endpoints'. That's how we have Dashboard changed to My Profile.
We can also hide existing endpoints by adding "//".
We can also adjust the order by, for example Orders to move to the beginning:

// Rename labels in My Account
add_filter ( 'woocommerce_account_menu_items', 'rms_woo_my_account_order' );
function rms_woo_my_account_order() {
$myorder = array(
'orders' => __( 'Orders', 'woocommerce' ),
'dashboard' => __( 'Mijn Profiel', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'edit-address' => __( 'Mijn Adres', 'woocommerce' ),
//'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $myorder;
}

There are many more possibilities with filters. Do you want to see more examples? Let us know in the comments.

Reader Interactions

Give a reaction