Pepe Sanz
Pepe Sanz

Reputation: 19

How to change email sender depending on order total in woocommerce?

I would like to change email sender, depending on order total value.

Example:

I cant figure out how to get $order dealing with email sender.

Thank you

Upvotes: 0

Views: 123

Answers (1)

Bipin Bheda
Bipin Bheda

Reputation: 36

You can use 'woocommerce_email_recipient_new_order' filter hook(Check here) to change sender email Please check below code you can get basic idea,

function wc_change_admin_new_order_email_recipient( $recipient, $order ) {
    global $woocommerce;
    if ( $order->get_total() > 100 ) { // Set your condition here and dump to know more about $order
        $recipient = "[email protected]";
    } else {
        $recipient = "[email protected]";
    }
    return $recipient;
}
add_filter('woocommerce_email_recipient_new_order', 'wc_change_admin_new_order_email_recipient', 1, 2);

Upvotes: 1

Related Questions