Change “From” Email Address for WooCommerce Stock Notices

I recently had a customer who noticed that WooCommerce stock notifications were sent from wordpress@site.com instead of the return email address set in the WooCommerce email settings. The stock notifications in WooCommerce use the default WordPress notification address which may be less than desirable. Most sites aren’t likely to even have that account set up!

Thankfully this is easy to change. Just add this snippet to your theme’s functions.php file or use a plugin like Code Snippets to add it.

function ijab_wp_sender_email( $original_email_address ) {
    return 'me@site.com';
} 
add_filter( 'wp_mail_from', 'ijab_wp_sender_email' );

function ijab_wp_sender_name( $original_email_from ) {
    return 'Your Site Name';
}
add_filter( 'wp_mail_from_name', 'ijab_wp_sender_name' );

You’ll want to replace the me@site.com with the email address you’d like to use and Your Site Name with the name you’d like the email to use. That’s it. You can still set the to address in the Product Inventory settings.

If you have any questions, let me know in the comments.


Leave a Reply

%d bloggers like this: