Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove dash board from WooCcommerce my account?

Tags:

woocommerce

I have a strange requirement from the client. I want to remove dashboard text. Instead,dashboard text I want to show the order details when my account pages load. ie /my-account/ shows the order details(content of /my-account/orders). I tried some wp-redirection, but its won't work.

like image 276
Vishnu Jayan Avatar asked Jan 05 '23 06:01

Vishnu Jayan


1 Answers

This is a pretty old question, but as I was just trying to solve the same problem figured I may as well share my solution. I did 3 things to accomplish this problem:

  • Remove "Dashboard" from the Account Navigation
  • Upon logging in, redirect the user to their Orders screen.
  • Copy the woocommerce/account/dashboard.php template into my local theme and remove all the content. Originally I would have rather automatically redirected away from this page, but at least this way the user doesn't see the "Hello Bob" text. It's also nice to keep this page for the logout confirmation message.

When logging in, send the user to their orders screen (bypassing the dashboard), unless its during checkout.

function WOO_login_redirect( $redirect, $user ) {

    $redirect_page_id = url_to_postid( $redirect );
    $checkout_page_id = wc_get_page_id( 'checkout' );

    if ($redirect_page_id == $checkout_page_id) {
        return $redirect;
    }

    return get_permalink(get_option('woocommerce_myaccount_page_id')) . 'orders/';

}

add_action('woocommerce_login_redirect', 'WOO_login_redirect', 10, 2);

Remove dashboard from Account navigation.

function WOO_account_menu_items($items) {
    unset($items['dashboard']);
    return $items;            
}

add_filter ('woocommerce_account_menu_items', 'WOO_account_menu_items');
like image 50
Louis W Avatar answered Jan 14 '23 04:01

Louis W