繁体   English   中英

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

[英]Include WooCommerce Address in New User Notification Email

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

我可以看到该电子邮件是通过...提取的

$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地址信息一起使用吗?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM