When a new order is created, woocommerce will send an email to admin, and I want it to send customer's city location inside the email as well.
Adding this code in function.php file will only show the IP requiring additional step to open browser and search for IP location to find the city:
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>';
}
There are clients placing fake orders using false address while this will show me the real city location.
So how can I display the customer City?
Code comes from: Display the customer IP Address in new order email notification