【发布时间】:2017-11-16 17:29:56
【问题描述】:
创建新订单后,woocommerce 会向管理员发送一封电子邮件,我希望它也可以在电子邮件中发送客户的城市位置。
在function.php文件中添加此代码将仅显示需要额外步骤才能打开浏览器并搜索IP位置以查找城市的IP:
add_action('woocommerce_email_customer_details', 'send_customer_ip_adress', 10, 4);
function send_customer_ip_adress($order, $sent_to_admin, $plain_text, $email){
// Just for admin new order notification
if( 'new_order' == $email->id )
echo '<br><p><strong>Customer IP address:</strong> '. get_post_meta( $order->id, '_customer_ip_address', true ).'</p>';
}
有些客户使用虚假地址下假订单,而这会显示真实的城市位置。
那么如何显示客户城市呢?
代码来自:Display the customer IP Address in new order email notification
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications