Change Reply To on Your Order Is Cancelled Email
-
I’m trying to update the “Reply To” email address on the “Your Order {Order Number} is Cancelled” email.
On the “Your {Company Name} order has been received!” email, the “Reply To” address is using the email configured in WooCommerce / Settings / Emails. This is the email I want to use.
When the customer receives the “Your Order {Order Number} is Cancelled” email, a “Reply To” address isn’t included, so if they click reply, the “To” field is populated with the “From” email address, which has been set in the WP Offload SES plugin settings. I don’t want to change this, as it would effect others emails within the site.
I’ve tried the following…add_filter('wp_mail', 'customize_woocommerce_reply_to_address'); function customize_woocommerce_reply_to_address($args){ if (isset($args['headers']) && is_array($args['headers'])) { foreach ($args['headers'] as &$header) { if (strpos($header, 'X-WC-Order') !== false) { if (strpos($args['message'], 'has been cancelled') !== false) { $new_reply_to_address = 'new-email@example.com'; $header = 'Reply-to: ' . $new_reply_to_address; break; } } } } return $args; }
Attempt 2…
add_filter('aws_ses_wp_mail_modify_message', 'customize_woocommerce_reply_to_address_ses', 10, 3); function customize_woocommerce_reply_to_address_ses($message_args, $to, $message){ if (isset($message_args['subject']) && strpos($message_args['subject'], 'is Cancelled') !== false) { $new_reply_to_address = 'new-email@example.com'; $message_args['headers'][] = 'Reply-to: ' . $new_reply_to_address; } return $message_args; }
Attempt 3…
add_filter('aws_ses_wp_mail_modify_message', 'customize_woocommerce_reply_to_address_ses', 10, 3); function customize_woocommerce_reply_to_address_ses($message_args, $to, $message) { if (isset($message_args['subject']) && strpos($message_args['subject'], 'is Cancelled') !== false) { $new_reply_to_address = 'new-email@example.com'; if (is_array($message_args['headers'])) { $message_args['headers'][] = 'Reply-To: ' . $new_reply_to_address; } else if (is_string($message_args['headers'])) { $message_args['headers'] = explode("\r\n", $message_args['headers']); $message_args['headers'][] = 'Reply-To: ' . $new_reply_to_address; } } return $message_args; }
Attempt 4…
add_filter( 'woocommerce_email_headers', 'customize_wc_email_headers', 10, 3 ); function customize_wc_email_headers( $headers, $email_id, $order ) { if ( $email_id === 'cancelled_order' ) { $headers .= 'Reply-to: new-email@example.com' . "\r\n"; } return $headers; }
Attempt 5…
add_filter( 'woocommerce_email_headers', 'change_reply_to_email_address', 10, 4 ); function change_reply_to_email_address( $header, $email_id, $order, $email ) { $reply_to_name = 'New Email'; $reply_to_email = 'new-email@example.com'; $header = "Content-Type: " . $email->get_content_type() . "\r\n"; $header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n"; return $header; }
If anyone knows how to achieve this, your input would be greatly appreciated.
- The topic ‘Change Reply To on Your Order Is Cancelled Email’ is closed to new replies.