Although, this may not be advisable.
If you want to get customer details, even when the user doesn’t create an account, but only makes an order, you could just query it, directly from the database.
Although, there may be performance issues, querying directly. But this surely works 100%.
You can search by post_id
and meta_keys
.
global $wpdb; // Get the global $wpdb
$order_id = {Your Order Id}
$table = $wpdb->prefix . 'postmeta';
$sql = 'SELECT * FROM `'. $table . '` WHERE post_id = '. $order_id;
$result = $wpdb->get_results($sql);
foreach($result as $res) {
if( $res->meta_key == 'billing_phone'){
$phone = $res->meta_value; // get billing phone
}
if( $res->meta_key == 'billing_first_name'){
$firstname = $res->meta_value; // get billing first name
}
// You can get other values
// billing_last_name
// billing_email
// billing_country
// billing_address_1
// billing_address_2
// billing_postcode
// billing_state
// customer_ip_address
// customer_user_agent
// order_currency
// order_key
// order_total
// order_shipping_tax
// order_tax
// payment_method_title
// payment_method
// shipping_first_name
// shipping_last_name
// shipping_postcode
// shipping_state
// shipping_city
// shipping_address_1
// shipping_address_2
// shipping_company
// shipping_country
}