Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active December 29, 2022 13:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save woogists/e30b0dd9e449c2b16433b97b0afe140e to your computer and use it in GitHub Desktop.
Save woogists/e30b0dd9e449c2b16433b97b0afe140e to your computer and use it in GitHub Desktop.
Change email subject lines
/*
* 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
**/
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);
$subject = sprintf( '[%s] New Customer Order (# %s) from Name %s %s', $blogname, $order->id, $order->billing_first_name, $order->billing_last_name );
return $subject;
}
@helgatheviking
Copy link

Needs to use getters for WC 3.0 or else you will get notices about directly accessing object properties.

$order->id, $order->billing_first_name, $order->billing_last_name

should be

$order->get_id(), $order->get_billing_first_name(), $order->get_billing_last_name()

@raindeer
Copy link

woocommerce_email_subject_customer_payment_retry shall actually be woocommerce_subscriptions_email_subject_customer_retry

@sobuzislam123
Copy link

what will be for bid on a product. It mean i am using woocommerce simple auction plugin. so what filter should i use for that to change the subject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment