Created
December 29, 2018 17:04
-
-
Save spigotdesign/a2735d18b8da7d101fe2fefa8b2df28d to your computer and use it in GitHub Desktop.
Filter New Order email headers for WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_email_header', 'spigot_reply_to_mail_filter', 11, 3); | |
function spigot_reply_to_mail_filter($headers = '', $ordertype = 'new_order', $order = '') { | |
if(!is_object($order) || empty($order) || $ordertype !== 'new_order') { return $headers; } | |
$name = $order->get_billing_first_name().' '.$order->get_billing_last_name(); | |
$email = $order->get_billing_email(); | |
if(is_array($headers)) { | |
$headers['Reply-To'] = "{$name} <{$email}>"; | |
} else { | |
$headers .= "Reply-To: {$name} <{$email}>\r\n"; | |
} | |
return $headers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment