How to get customer details from an order in WooCommerce

In this tutorial we are going to look at the different ways to get customer details from order in WooCommerce.

There are a few ways that you can get customer order details in WooCommerce. One way is to go to the orders page and click on the order that you want to view. This will take you to the order details page where you can see all of the information about the order, including some of customer details like the customer’s name, shipping address, and email. But if you want to access all of the customer details that your WooCommerce store has there isn’t an out of the box way to do it.

In this article we are going to explore two different ways to get customer details from order data. The first and the main method covered in this article will on how to get the customer details programmatically from the WooCommerce order object. For for that we first will need to get access to the WooCommerce order object.

woocommerce customers details from order

How to get WooCommerce order data

If you have the order id available, you can access the order by using the wc_get_order WooCommerce function. You can use get methods from WC_Order  and WC_Abstract_Order  classes on the WC_Order object instance by using the $order_id like this:

Now that we have the order object we have access to all the details associated with that specific order, including the customer details.

How to get customer order details programmatically from the WC_Order object

The WC_ Order object contains the regular WooCommerce orders, which extend the abstract order class. We have covered the WC_Order class in details in our previous article. In this tutorial we are going to only focus on getting the WooCommerce order details that are relevant to the  customer.
In the following example we’ll see how to get the following details from WooCommerce order:
  • get customer id and user id
  • get the user object
  • get the user roles
  • get the customer billing email
  • get customer phone number

 

As you can see once you have access to the WooCommerce order object you can get a lot of customers details (and user info) that are related to that order. How let’s see how to get customer billing information and customer shipping information from the order data:

The code above demonstrates how to use the WooCommerce wc_get_order function to create an order object. Once you have created the object, you can use different methods to get information about the user, such as their name and address.

How to use the the WC_Order get_data() method

You can also use the get_data() method, to get an unprotected data array from Order meta data like:

 

How to get customer details from order without code

If you want to get all the customer details based on a particular WooCommerce order but you are not looking for a coding solution you can do it with the help of Users Insights. If you have the plugin installed and active on your WooCommerce store,  Users Insights will create an advanced WooCommerce customer profile that has all the available customer details in once place. The plugin also automatically links WooCommerce order details with the WooCommerce customer details. Additionally, it adds a link to every order item in WooCommerce to the corresponding WooCommerce customer profile. To find the customer details associated with a specific order first you will need to navigate the WooCommerce -> Orders list in your WordPress dashboard.

woocommerce customer details

Once you find the specific order that you are looking for click and open the order page.

woocommerce customer details from order

There under the customers name you will see a “Users Insights Profile →” link. This links to the WooCommerce customer profile page of the customer who have purchased the order and from there you can get all the customer details that you might need.

woocommerce customer get details