I’m using Woocommerce Version 4.8.0 I have a problem with my account page I want to change all the URLs like the image down below:
I have found on stackoverflow the solution for it but the code change only one URL not all of them
add_filter('woocommerce_get_endpoint_url', 'woocommerce_hacks_endpoint_url_filter', 10, 4); function woocommerce_hacks_endpoint_url_filter($url, $endpoint, $value, $permalink) { $downloads = get_option('woocommerce_myaccount_downloads_endpoint', 'downloads'); if (empty($downloads) == false) { if ($endpoint == $downloads) { $url = '//example.com/customer-area/dashboard'; } } return $url; }
Any help?
Advertisement
Answer
All related endpoints slugs can be found on WooCommerce settings > Advanced (tab) > Account endpoints:
Then you can use a switch statement to change the required account endpoints URLs as follows:
add_filter('woocommerce_get_endpoint_url', 'change_my_account_endpoint_urls', 10, 4); function change_my_account_endpoint_urls( $url, $endpoint, $value, $permalink ) { switch($endpoint){ case 'orders': $url = home_url('/customer-area/the-orders/'); break; case 'downloads': $url = home_url('/customer-area/the-downloads/'); break; case 'edit-address': $url = home_url('/customer-area/the-edit-address/'); break; case 'edit-account': $url = home_url('/customer-area/new-edit-account/'); break; case 'payment-methods': $url = home_url('/customer-area/the-payment-methods/'); break; } return $url; }
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
To change the My account URL itself, you need to edit the my account page in backend and change its permalink (editing the URL slug).