要保障 woocommerce 安全反欺诈的话有相关插件可以用,要订单显示 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 ){
// WC3+ compatibility
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
echo '<br><p><strong>Customer IP address:</strong> '. get_post_meta( $order_id, '_customer_ip_address', true ).'</p>';
}
}
没有直接在订单细节里显示的,邮件可以。