Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add customer name to WooCommerce Admin New Order Email subject
<?php // only copy this line if needed!
/**
* Adds customer first and last name to admin new order email subject.
*
* @param string $subject email subject
* @param \WC_Order $order the order object for the email
* @return string updated subject
*/
function skyverge_add_customer_to_email_subject( $subject, $order ) {
$subject .= ' from ' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
return $subject;
}
add_filter( 'woocommerce_email_subject_new_order', 'skyverge_add_customer_to_email_subject', 10, 2 );
@Uriel1339

This comment has been minimized.

Copy link

@Uriel1339 Uriel1339 commented Feb 27, 2020

That is outdated. Please see revised below:

// Adds customer first and last name to admin new order email subject
function skyverge_add_customer_to_email_subject( $subject, $order ) {
	$subject = '[J.N. Equipment Superstore] New Customer Order - (# ' . $order->get_order_number() . ') from ' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
	return $subject;
};
add_filter( 'woocommerce_email_subject_new_order', 'skyverge_add_customer_to_email_subject', 10, 2 );

Giving quite some PHP errors / notices since WooCommerce 3.0 if you don't update it to '$order->get_...' :)

@2TheMooon

This comment has been minimized.

Copy link

@2TheMooon 2TheMooon commented Jul 10, 2020

if i want product name Was Sold how to do that?

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