Hey I would like to change the reply to emailadress for the new_order emails based on the shipping item.
I have tried:
add_filter( 'woocommerce_email_headers', 'add_headers_replay_to_conditionally', 10, 3 );
function add_headers_replay_to_conditionally( $headers, $email_id, $order ) {
// Avoiding errors
if ( ! is_a( $order, 'WC_Order' ) || ! isset( $email_id ) )
return $headers;
// The defined emails notifications to customer
$allowed_email_ids = array('customer_on_hold_order', 'woocommerce_new_order');
$shipping_items = $order->get_items('shipping');
$shipping_item = reset($shipping_items);
$shipping_name = $shipping_item->get_name();
if ( $shipping_name == 'Afhalen in Utrecht' ) {
$headers .= "Reply-to: utrecht@x.nl". "\r\n";
}
elseif ( $shipping_name == 'Bezorgen vanuit Utrecht' ) {
$headers .= "Reply-to: utrecht@x.nl". "\r\n";
}
elseif( $shipping_name == 'Afhalen in Amsterdam' ) {
$headers .= "Reply-to: amsterdam@x.nl". "\r\n";
}
elseif( $shipping_name == 'Bezorgen vanuit Amsterdam' ) {
$headers .= "Reply-to: amsterdam@x.nl". "\r\n";
}
elseif( $shipping_name == 'Bezorgen in Amersfoort (gratis vanaf €50 ex btw bestelwaarde)' ) {
$headers .= "Reply-to: amersfoort@x.nl". "\r\n";
}
else {
$headers .= "Reply-to: info@x.nl". "\r\n";
}
return $headers;
}
But I get the "new" email adres (based on shipping item) + the standaard email adres in the reply to field.. I would like to have only the new one.