Solved

Woocommerce 2.6 - Get customer details from completed order

Posted on 2016-08-22
2
754 Views
Last Modified: 2016-08-24
Hi,

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.
0
Comment
Question by:MahargNala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
William Nettmann earned 500 total points
ID: 41766416
What does $order->customer_user return? That may be the user ID of the customer.
0
 

Author Closing Comment

by:MahargNala
ID: 41768483
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
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question