Skip to content

Instantly share code, notes, and snippets.

@spigotdesign
Created December 29, 2018 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spigotdesign/a2735d18b8da7d101fe2fefa8b2df28d to your computer and use it in GitHub Desktop.
Save spigotdesign/a2735d18b8da7d101fe2fefa8b2df28d to your computer and use it in GitHub Desktop.
Filter New Order email headers for WooCommerce
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