WooCommerce

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.

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.

/* * Change the order of the endpoints that appear in My Account Page - WooCommerce 2.6 * The first item in the array is the custom endpoint URL - ie http://mydomain.com/my-account/my-custom-endpoint * Alongside it are the names of the list item Menu name that corresponds to the URL, change these to suit */
function wpb_woo_my_account_order() { $myorder = array( 'my-custom-endpoint' => __( 'My Stuff', 'woocommerce' ),
		'edit-account'       => __( 'Change My Details', 'woocommerce' ),
		'dashboard'          => __( 'Dashboard', 'woocommerce' ),
		'orders'             => __( 'Orders', 'woocommerce' ),
		'downloads'          => __( 'Download MP4s', 'woocommerce' ),
		'edit-address'       => __( 'Addresses', 'woocommerce' ),
		'payment-methods'    => __( 'Payment Methods', 'woocommerce' ),
		'customer-logout'    => __( 'Logout', 'woocommerce' ),
	);

	return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );

Note: There is 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.

<?php
/*
 * Change the entry title of the endpoints that appear in My Account Page - WooCommerce 2.6
 * Using the_title filter
 */

function wpb_woo_endpoint_title( $title, $id ) {

	if ( is_wc_endpoint_url( 'downloads' ) && in_the_loop() ) { // add your endpoint urls
		$title = "Download MP3s"; // change your entry-title
	}

	elseif ( is_wc_endpoint_url( 'orders' ) && in_the_loop() ) {
		$title = "My Orders";
	}

	elseif ( is_wc_endpoint_url( 'edit-account' ) && in_the_loop() ) {
		$title = "Change My Details";
	}
	return $title;
}

add_filter( 'the_title', 'wpb_woo_endpoint_title', 10, 2 );