Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get customers name in confirmation email

I am working with Woocommerce and I am about to make the order confirmation email.

It want the mail to say:

"Hi [customers name]"

How do you get Woocommerce to print the customers name?

like image 251
Frederik Skøt Avatar asked Jul 23 '13 19:07

Frederik Skøt


People also ask

What types of information are found in email order confirmations?

An order confirmation email is a transactional email sent to a customer once they've completed a transaction in an online store. As the name suggests, this email contains a buyer's order confirmation details, including what they bought, the purchase total, and the estimated delivery date.


1 Answers

You need the order object, so depending on what hook you are using it should be there. Try something like this:

add_action('woocommerce_order_status_completed','my_woo_email');
function my_woo_email($order_id){

           $order = new WC_Order( $order_id );
           $to = $order->billing_email;
           $subject = 'this is my subject';
           $message = 'Hi '.$order->billing_first_name.' '.$order->billing_email;$order->billing_last_name.', thanks for the order!';

                woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/htmlrn", $attachments = "" )

}

This is untested but should get you started

like image 97
Kyle Avatar answered Sep 21 '22 13:09

Kyle