Solved

Woocommerce 2.6 - Get customer details from completed order

Posted on 2016-08-22
2
387 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fix Datetime in MySQL? 4 48
mysql query for sum() 3 28
jQuery force form POST 7 44
PHP 5.6 and 7.x 4 20
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn about the eCommerce marketing trends for the year ahead.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

840 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