Change, Edit & Rename WooCommerce Endpoints in My Accounts Page
Here is how you can change, edit and rename WooCommerce Endpoints in My Accounts Page.
Since the release of WooCommerce 2.6 Woo has a revamped My-Account page, it appears as a vertical menu of links that display the corresponding table of data to the right, similar to a tabbed layout. This certainly is a better user experience than the previous continuous rolling display of data.
The usual data found on the My Account page will be in this format including WooCommerce subscriptions and memberships. These segments are contained in what is called endpoints.
Changing the My Account Endpoints Order
The original order of the My Account menu items can be seen in /wp-content/plugins/woocommerce/includes/wc-account-functions.php
/** * Get My Account menu items. * * @since 2.6.0 * @return array */ function wc_get_account_menu_items() { return apply_filters( 'woocommerce_account_menu_items', array( 'dashboard' => __( 'Dashboard', 'woocommerce' ), 'orders' => __( 'Orders', 'woocommerce' ), 'downloads' => __( 'Downloads', 'woocommerce' ), 'edit-address' => __( 'Addresses', 'woocommerce' ), 'payment-methods' => __( 'Payment Methods', 'woocommerce' ), 'edit-account' => __( 'Account Details', 'woocommerce' ), 'customer-logout' => __( 'Logout', 'woocommerce' ), ) ); }
You can change the order of these endpoints by using the woocommerce_account_menu_items filter, you can also change the list item title with the same filter.
One of the limitations with changing the list item title is that it won’t change the entry-title.
To remove an item from the my-account dashboard don’t include it in the returned array that you are passing in via the filter woocommerce_account_menu_items
Changing the Entry Title of the Custom Endpoint
One way around changing the entry-title of the WooCommerce custom endpoint is to use the_title filter with the in_the_loop conditional.
Now the entry title, as well as the list item title, are changed.
Adding a Custom Endpoint
@claudiosmweb has published an example of how to add a new custom endpoint to the menu list on the My Account page, which is great as you can add any additional data into it.
So in the code above you add as a plugin, I have added the plugin header, so just add in your plugins folder and activate and then flush your permalinks. Change the content where applicable it is set up to use ‘My Stuff‘ as the Entry Title with an endpoint as my-custom-endpoint and an echo of Hello World.
To change the custom endpoint URL just change it and ensure you change the corresponding URL value in anything added in via the filter in woocommerce_account_menu_items
Adding Content to the Custom Endpoint
To change the content itself you can add in a template or use a woo provided filter…
add_action( 'woocommerce_account_my-stuff-endpoint_endpoint', 'gc_custom_endpoint_content' ); /** * Custom Endpoint content */ function gc_custom_endpoint_content() { echo 'custom end point content goes here'; }
So in the above, the action used is woocommerce_account_{your-custom-url}_endpoint – just hook in your content.