I have a function that does this:
$order = new WC_Order($order_id); $customer = new WC_Customer($order_id);
How can I get customer details fr
WooCommerce is using this function to show billing and shipping addresses in the customer profile. So this will might help.
The user needs to be logged in to get address using this function.
wc_get_account_formatted_address( 'billing' );
or
wc_get_account_formatted_address( 'shipping' );