Solved

Woocommerce 2.6 - Get customer details from completed order

Posted on 2016-08-22
2
90 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
2 Comments
 
LVL 12

Accepted Solution

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

Author Closing Comment

by:MahargNala
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now