How to Send Checkout Details to Email Recipients in WooCommerce?

Sometimes, you wish to create additional email templates. Imagine where your customer has checked out purchasing a product. You wish to send a customized Thank You message to this user’s Twitter ID. Or else, you want to communicate a new customer shipping address to dropshipper. In both these circumstances, you need to generate an email reminder. So, let’s learn how to send checkout details to email recipients. 

Doing so, you can transfer user info after a new order is placed. This way, you can build personalized bonds with your user by sending a Thank You note. In case you are delivering this address communication message to dropshipper, then you can stay assured of right shipment delivery. 

Let’s see how you can code it.

Image showing user checkout details sent to email recipients

PHP Snippet: WooCommerce Send Checkout Details to Email Recipients

add_action( 'woocommerce_checkout_update_user_meta', 'phpsof_checkout_field_update_user_meta' );
  
function phpsof_checkout_field_update_user_meta( $user_id ) { 
    
if ( $user_id && $_POST['twitter'] ) {
    
   // if custom input field name = "twitter" >> then use $_POST['twitter']
   phpsof_email_with_twitter_username( $_POST['twitter'] );
    
}
    
}
 
function phpsof_email_with_twitter_username( $username ) {
 
      $to = 'info@phpsof.com';
       $subject = 'Reminder: New PHPSOF Fan to Thank on Twitter';
       $message = 'Hey , please remember to send a Tweet to: ' . $username;
     
      wp_mail( $to, $subject, $message );
    
}

Where do you add this snippet?

So, this is how you can send checkout details to email recipients. Also, it is easier to activate this function with this code. So, to apply this code, just add this PHP snippet at your child theme function.php file’s bottom. It should be placed before “?>”, if you have it there. Apart from this, CSS goes in your child theme style.css file. Make sure that you are editing these files in a right manner for best results.

Is this snippet still valid?

So, this is how you can learn about send checkout details to email recipients. I have applied this code on the Storefront theme and WordPress friendly hosting PHP 7.3. Let me know if everything works as expected when you code. Share it further if you find this snippet useful for you and it had saved your time. 

Also Read, How to Display Shipping Message After Country Selection at Checkout?

How to Add Checkout Fee for Payment Gateway in WooCommerce?

Important links: WooCommerce – https://woocommerce.com/