This will add a “Customer Orders” link on the customer/user profile edit page. Handy when trying to find a full history of a customer’s orders.
// Show a link to the list of orders for a user
function myprefix_user_orders_link(WP_User $user) {
if (!ssc_is_admin()) {
return;
}
$link = admin_url('edit.php?s&post_type=shop_order&_customer_user='.$user->ID);
echo '<tr><td colspan="2"><a href="' . $link . '" class="button">Customer Orders</a></td></tr>';
}
add_action('personal_options', 'myprefix_user_orders_link');
To add the link to the Users list:
function myprefix_user_list_send_password_reset_email_link($actions, $user) {
$link = admin_url('edit.php?s&post_type=shop_order&_customer_user='.$user->ID);
$actions['customer_orders'] = '<a href="' . $link . '">Customer Orders</a>';
return $actions;
}
add_filter('user_row_actions', 'myprefix_user_list_send_password_reset_email_link', 80, 2);