Jon
Jon

Reputation: 361

WordPress WooCommerce Change Account Orders Page Query

I'd like to modify the MyAccount/Orders page to use a custom query. Basically I want to pull in all orders across users with a specific matching user meta field.

I have this query working and combining orders on a separate page but I'd like to edit the actual orders page. Here is what I have so far.

function my_show_orders($args) {
    $user_id = get_current_user_id();
    $meta_key = 'AccountNumber';
    $AccountNumber = get_user_meta($user_id, $meta_key, true);
    $shared_account_ids = my_function_get_users_by_meta_value($meta_key, $AccountNumber);

    $args['customer_id'] = $shared_account_ids;

    return $args;
}

add_filter('woocommerce_my_account_my_orders_query', 'my_show_orders', 20);

I double checked and $shared_account_ids does hold the IDs of the users I want to display orders from BUT I'm still only getting the current user's orders.

Upvotes: 2

Views: 39

Answers (0)

Related Questions