Reputation: 23
"Reviews can only be left by 'verified owners'" is checked. And the billing address inputs are mandatory.
The code is inside a function call on woocommerce_review_before_comment_text
hook.
The closest I've been to is:
$user_data = get_user_by('id', $comment->user_id);
, but customer address is not there.
Upvotes: 2
Views: 3230
Reputation: 992
welcome to the community.
In order to get the billing address you need to fetch user meta data instead of user object, unless you want the user object too. So you code should be like it is shown below:
$billing_address_1 = get_user_meta( $comment->user_id, 'billing_address_1', true );
$billing_address_2 = get_user_meta( $comment->user_id, 'billing_address_2', true );
$billing_city = get_user_meta( $comment->user_id, 'billing_city', true );
$billing_state = get_user_meta( $comment->user_id, 'billing_state', true );
$billing_country = get_user_meta( $comment->user_id, 'billing_country', true );
$billing_postcode = get_user_meta( $comment->user_id, 'billing_postcode', true );
You can concatenate this to build a complete address or use them individually as per your choice.
Upvotes: 5