【问题标题】:Display the customer city in new order email notification在新订单邮件通知中显示客户所在城市
【发布时间】: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


    【解决方案1】:

    您可以这样添加客户 IP 地址,也可以添加他的计费城市:

    add_action( 'woocommerce_email_customer_details', 'send_customer_city', 10, 4 );
    function send_customer_city( $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>
            <p><strong>'.__('Customer city').':</strong> '. get_post_meta( $order->get_id(), '_billing_city', true ).'</p>';
        } 
    } 
    

    代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件中。

    经过测试并且可以工作

    【讨论】:

      猜你喜欢
      • 2018-06-07
      • 1970-01-01
      • 2015-02-05
      • 2018-04-24
      • 2021-09-05
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 2015-06-13
      相关资源
      最近更新 更多