1
votes

I need to change the order email sender to customer email.

The function change return the email is:

public function get_from_address() {
        $from_address = apply_filters( 'woocommerce_email_from_address', get_option( 'woocommerce_email_from_address' ), $this );
        return sanitize_email( $from_address );
    }

Does it exist a filter that I can get the sender email customer email? I need that provider from product receive the email from customer, so he can reply more easy.

1

1 Answers

1
votes

Try to use the following:

// Change email sender name
add_filter( 'woocommerce_email_from_name', 'custom_email_from_name', 20, 2 );
function custom_email_from_name( $from_name, $wc_email ){
    // Get the WC_Order object instance
    $order = $wc_email->object;

    $from_name = $order->get_formatted_billing_full_name(); // Customer ful name

    return $from_name;
}

// Change email sender address
add_filter( 'woocommerce_email_from_address',  'custom_email_from_address', 20, 2 );
function custom_email_from_address( $from_email, $wc_email ){
    // Get the WC_Order object instance
    $order = $wc_email->object;

    $from_email = $order->get_billing_email(); // Customer billing email

    return $from_email;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.