lundi 5 octobre 2015

WC - change From email only in the new order email

I want to change the From email when email about a new order is sending in WooCommerce. I know that I can use wp_mail_from filter but my issue is that I don't know how to determine that the WC_Email_New_Order email is sending and not some other one.

I tried something like this:

function prefix_set_from_email( $email ) {
    $mailer = WC()->mailer();
    $new_order_email = $mailer->emails['WC_Email_New_Order'];
    if ( null !== $new_order_email->object && is_email( $_POST['billing_email'] ) ) {
        $email = $_POST['billing_email'];
    }
    return $email;
}
add_filter( 'wp_mail_from', 'prefix_set_from_email', 50 );

But it change the address when WC_Email_Customer_Completed_Order email is sending too. Any advice? :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire