I'm trying to include the address entered by a customer, in the email received by the admin.
I can see that the email is being pulled in via...
$user->user_email
which is obtained via...
$user = get_userdata( $user_id );
I thought something along the following would work to pull the post code in...
$user->user_postcode
http://codex.wordpress.org/Function_Reference/get_userdata suggests that...
get_userdata
and
get_user_meta
can't be used to pull WooCommerce address info in, so I looked for something that would pull this information in and tried...
global $woocommerce;
$test = get_user_meta( $current_user->ID, 'billing_postcode', true );
with...
$message .= sprintf(__('Post Code: %s'), $test) . "\r\n";
Would someone be able to inform me of a similar option to get_userdata that will work with WooCommerce address info?
global $woocommerce;
$customer_address = $woocommerce->customer->get_address();
$customer_address_2 = $woocommerce->customer->get_address_2();
$customer_city = $woocommerce->customer->get_city();
$customer_state = $woocommerce->customer->get_state();
$customer_postcode = $woocommerce->customer->get_postcode();
$message .= sprintf(__('Address Line 1: %s'), $customer_address) . "\r\n\r\n";
$message .= sprintf(__('Address Line 2: %s'), $customer_address_2) . "\r\n\r\n";
$message .= sprintf(__('City: %s'), $customer_city) . "\r\n\r\n";
$message .= sprintf(__('County: %s'), $customer_state) . "\r\n\r\n";
$message .= sprintf(__('Post Code: %s'), $customer_postcode) . "\r\n";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.