Answer the question
In order to leave comments, you need to log in
How to send an IP address in a letter to the Woocomerce administrator?
Good afternoon. I have a question. When placing an order on the Woocommerce website, an email is sent to the store owner with information about the order and the buyer. You need to make sure that the IP address of the buyer with all this information is also sent. Which file should I edit? I already know where the template for this letter is located, but I did not find anything necessary there.
Answer the question
In order to leave comments, you need to log in
Solved the problem. I paste the code if someone needs it in the future (we paste it into functions.php):
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>';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question