在新用户通知电子邮件中包含WooCommerce地址

时间:2014-02-05 14:43:04

标签: php wordpress notifications woocommerce

我试图在管理员收到的电子邮件中包含客户输入的地址。

我可以看到电子邮件正在通过...

进入
$user->user_email

通过......获得

$user = get_userdata( $user_id );

我认为以下内容可以将后置代码拉入...

$user->user_postcode

http://codex.wordpress.org/Function_Reference/get_userdata表明......

get_userdata

get_user_meta

无法用来提取WooCommerce地址信息,所以我找了一些可以提取此信息的内容并尝试了...

global $woocommerce;
$test = get_user_meta( $current_user->ID, 'billing_postcode', true );

...与

$message .= sprintf(__('Post Code: %s'), $test) . "\r\n";

有人能告诉我一个类似的get_userdata选项可以使用WooCommerce地址信息吗?

1 个答案:

答案 0 :(得分:0)

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";