当客户进入到他们的WooCommerce账号界面时,默认打开的是 Dashboard,这个界面其实没有什么卵用,所以我们可以更改WooCommerce用户账户中默认显示的标签页,指定首先看到的页面。例如,希望优先显示订单。
用户默认标签页代码
老规矩,把代码添加到自定义代码插件上或者添加代码到主题的functions.php上。
add_action( 'template_redirect', 'jhchen_my_account_default_orders' );
function jhchen_my_account_default_orders(){
if ( is_account_page() && empty( WC()->query->get_current_endpoint() ) ) {
wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
exit;
}
}
这个代码你要注意的是,endpoint 必须和你需要默认显示的 tab 一致。订单页默认就是 “orders”。下面你也会看到下载界面端点被删除了,因为大多数电商网站都不需要
