When a new order is created, woocommerce will send an email to admin, and I want it to send customer's IP address inside the email as well. But I can't get it work, here is what I got so far:
<?php echo get_post_meta( $order->id, '_customer_ip_address', true ); ?>
This code goes in mytheme/woocommerce/emails/admin-new-order.php
Any ideas?
Thanks.
(added compatibility for WooCommerce versions 3+)
You can use any related hooks for the emails notifications and you don't need to override the WooCommerce emails templates.
In the example below, the customer IP address will be displayed just before the customer details,
using woocommerce_email_customer_details
hook:This code is tested and is fully functional.
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.