要保障 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>';
}
}
沒有直接在訂單細節裏顯示的,郵件可以。