If you want to get customers name in confirmation email in WooCommerce? Use following code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** * Get customers name in confirmation email in WordPress. */ function fwm_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 = "" ) } add_action('woocommerce_order_status_completed','fwm_woo_email'); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.