7

I've seen loads of example of how to re-order / change the navigation and page with the WooCommerce my account dashboard. But i can't for the life of me work out how to change the main titles for each section (My Account, Orders, Downloads, Addresses etc).

I've searched through the templates but no joy. I've tried using conditional php comments to echo the titles for the correct page. But it doesn't work because my account section uses endpoints. I've tried adding a filter, but no joy. Anyone got any idea how i change these titles?

Thanks

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
alexkodr
  • 523
  • 3
  • 7
  • 30

3 Answers3

7

It can be done using the composite filter hook woocommerce_endpoint_{$endpoint}_title.

For example if you need to change the My Account "** Account details**" title you will use (where the endpoint is edit-account):

add_filter( 'woocommerce_endpoint_edit-account_title', 'change_my_account_edit_account_title', 10, 2 );
function change_my_account_edit_account_title( $title, $endpoint ) {
    $title = __( "Edit your account details", "woocommerce" );

    return $title;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

enter image description here

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
0

Found I can do using woo_endpoint_title filter.

alexkodr
  • 523
  • 3
  • 7
  • 30
  • Sorry but your answer is wrong as this is not the right hook to be used… – LoicTheAztec Nov 22 '18 at 23:21
  • Ahh i see so i should be using the correct filter 'woocommerce_endpoint_edit-account_title' and change to match the correct endpoint. Do you know how to change the main account page title? /my-account/ because this page doesn't have an endpoint? See here: https://gomy.co.uk/my-account-title.jpg – alexkodr Dec 03 '18 at 09:10
  • "My account" is not an end point but a page title that you can set in the backend Wordpress pages changing the title name of your page. Be sure after that it's yet selected in Woocommerce > settings > Advanced (You will also see there all the end points). Also you might could delete this answer as it's not useful to the community. – LoicTheAztec Dec 03 '18 at 09:23
0

This worked for me to rename the titles of all my account pages:

function wpb_woo_endpoint_title( $title, $id ) {
           
            if ( is_wc_endpoint_url( 'orders' ) && in_the_loop() ) {
                $title = "Deine Buchungen";
            }
            elseif ( is_wc_endpoint_url( 'edit-address' ) && in_the_loop() ) {
                $title = "Deine Rechnungs- & Behandlungsadresse"; 
            }
            elseif ( is_wc_endpoint_url( 'payment-methods' ) && in_the_loop() ) {
                $title = "Deine Bezahlmethoden";  
            }
            elseif ( is_wc_endpoint_url( 'edit-account' ) && in_the_loop() ) {
                $title = "Dein Nutzerkonto"; 
            }
            return $title;
        }
        add_filter( 'the_title', 'wpb_woo_endpoint_title', 10, 2 ); 
AlphaX
  • 615
  • 1
  • 11
  • 25