I'm using WooCommerce plugin in Wordpress.
I would like to change the URL of the "Downloads" link that appears on "my-account" page created by WooCommerce.
I want to change it from linking to /my-account/downloads/
to /customer-area/dashboard/
I tried to add a custom function that changed the titles and endpoints of menu items.
function wpb_woo_my_account_order() {
$myorder = array(
'edit-account' => __( 'Change My Details', 'woocommerce' ),
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'customer-area/dashboard' => __( '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' );
However, whatever endpoint I use, it remains nested inside /my-account/
How can I change that?
The way I've done that in the past is to change the endpoint URL via the Woocommerce woocommerce_get_endpoint_url
filter, like this:
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;
}
Obviously, change the $url
variable to suit your environment. The reason we use the get_option()
function is because you can change the endpoints in Woocommerce settings, which means downloads
may not be your specific endpoint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With