• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1421
  • Last Modified:

Woocommerce 2.6 - Get customer details from completed order


I have an add action to call a function once an order has been marked as completed

add_action( 'woocommerce_order_status_completed', array( $this, 'callback_function_name'),10, 1 );

Open in new window

within the function I am getting the order information based on the order ID

public function callback_function_name($order_id) {
        $order = new WC_Order($order_id); 
        $items = $order->get_items(); 
        foreach ( $items as $k => $item ) {
                $product_name = $item['name'];

Open in new window

I am not allowing guest access as the items will be downloads, so they need to sign in to download their items.

I need to get the customers information from that order as I need to send the customers ID, Name and email address to another process.

I have done some searching online, but not come across an answer that actually works.

Look forward to someones help on this matter.
1 Solution
William NettmannPHP Web DeveloperCommented:
What does $order->customer_user return? That may be the user ID of the customer.
MahargNalaAuthor Commented:
This pointed me in the right direction thanks, I was then able to use

$user_info = get_userdata($user_id);

to get the rest of the information I needed
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now