Hi, friends hope you are doing good, Today I am going to share very useful things How to Change Woocommerce email subject lines. In my recent project, my client asks to add the custom subject of all emails from his WooCommerce store. Below is the very simple code that will change email subject lines.
Never try to change in WooCommerce core files to change WooCommerce email subject lines, because it is very bad idea to do. In case if done that, you will loose your custom changes if WooCommerce plugin will update.
Below are the email filters to change the email subject line as you want. This is the simple filter which will override the default email subjects line. Use below filters in functions.php page of the current theme.
If you don’t want to add filters to your functions.php page, then you can also create a custom WordPress plugins for the same.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * goes in theme functions.php or a custom plugin * * Subject filters: * woocommerce_email_subject_new_order * woocommerce_email_subject_customer_processing_order * woocommerce_email_subject_customer_completed_order * woocommerce_email_subject_customer_invoice * woocommerce_email_subject_customer_note * woocommerce_email_subject_low_stock * woocommerce_email_subject_no_stock * woocommerce_email_subject_backorder * woocommerce_email_subject_customer_new_account * woocommerce_email_subject_customer_invoice_paid **/ |
Apply WooCommerce Extra Fee
Woocommerce Search order by SKU
Integrate ccavenue payment gateway woocommerce
Getting Started With WooCommerce For Your Online Store
See below example how woocommerce_email_subject_new_order
filter is override the default email subject line for new orders email.
1 2 3 4 5 6 7 8 9 10 11 12 13 | add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2); function change_admin_email_subject( $subject, $order ) { global $woocommerce; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // Change subject according to your requirement $subject = sprintf( '[%s] New Customer Order (# %s) from Name %s %s', $blogname, $order->id, $order->billing_first_name, $order->billing_last_name ); return $subject; } |
You can change above functions as per your requirements using different filters. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: change email subject lines, email subject, Freebies, Tip and tricks, wocommerce email, woocommerce, wordpress