WooCommerce Get User Details By User ID

Hi Guys,

In WooCommerce, you can fetch all the user details by user id using get_user_meta() function.
If you want to get the user details by user id, you can use the following code snippet:

$customer_id = '10';
$customerData = get_user_meta($customer_id);
$first_name = isset($customerData['first_name'][0]) ? $customerData['first_name'][0] : '';
$last_name = isset($customerData['last_name'][0]) ? $customerData['last_name'][0] : '';
$companyName = isset($customerData['billing_company'][0]) ? $customerData['billing_company'][0] : '';
$billing_address_1 = isset($customerData['billing_address_1'][0]) ? $customerData['billing_address_1'][0] : '';
$billing_city = isset($customerData['billing_city'][0]) ? $customerData['billing_city'][0] : '';
$billing_postcode = isset($customerData['billing_postcode'][0]) ? $customerData['billing_postcode'][0] : '';
$billing_state = isset($customerData['billing_state'][0]) ? $customerData['billing_state'][0] : '';
$phone = isset($customerData['billing_phone'][0]) ? $customerData['billing_phone'][0] : '';
$billing_email = isset($customerData['billing_email'][0]) ? $customerData['billing_email'][0] : '';

That’s it! You are done.

Leave a Reply