Email Subject Line

Change the default subject line used in emails

wppizza_filter_email_subject

/*** 
	email subject lines are made up of 3 parts 
	filter each part as required based on your preferences

****/
add_filter('wppizza_filter_email_subject', 'myprefix_filter_email_subject', 10, 2);
function myprefix_filter_email_subject($subject, $order_formatted){

	/*
		defaults

		//dynamic depending on settings in wppizza order form , but typically its the site name plus perhaps some personal info */
		$subject['prefix'] 	= '[--------- conditional/dynamic text ---------------]' ;
	
		//from wppizza->localization
		$subject['main'] 	= $order_formatted['localization']['your_order'];
	
		//date/time according to wordpress date/time settings */	
		$subject['suffix'] 	= date_i18n($order_formatted['date_format']['date'], WPPIZZA_WP_TIME)." ".date_i18n($order_formatted['date_format']['time'], WPPIZZA_WP_TIME)."";

		//This typically produces something like
		"My Shop Your Order March 25, 2020 6:31 pm" 
		where:
		$subject['prefix'] = 'My Shop';
		$subject['main']= 'Your Order';
		$subject['suffix']= 'March 25, 2020 6:31 pm';
	*/

	// example: if you want to not add the date/time at the end
	$subject['suffix'] = '';	
	//or simply
	unset($subject['suffix']);	

	// example: change the typically main "My Order"
	$subject['main'] 	= 'whatever it is you want';

	// example: add something after it all
	$subject['some_additional_key'] 	= 'something added to the end of the subject line;

	/*
		for conditionals depending on order values, 
		you can use the 2nd "$order_formatted" parameter
	*/

return $subject;
}

As of version 3.6.7+ an additional parameter has been added to the filter with the order details already formatted

add_filter('wppizza_filter_email_subject', 'prefix_filter_email_subject', 10 , 3);
function prefix_filter_email_subject($subject, $order, $order_formatted){

	/* 
	$subject is an array made up of 
	$subject['prefix'] - typically contains blogname followed by items added to subject line in wppizza->order form 
	$subject['main'] - typically contains "your order" localization string (wppizza->localization)
	$subject['suffix'] - typically contains date of order according to date/time format set in WP->settings
	*/
	
	/* example: adding the label of a gateway as set in wppizza->gateways after the prefix , tweak as required*/	
	$subject['prefix'] .= ' '.$order_formatted['ordervars']['payment_type']['value_formatted'];
	
	/* example2: adding the paymet method (i.e typically simply  "Cash" or "Credit Card" ) , tweak as required*/	
	$subject['prefix'] .= ' '.$order_formatted['ordervars']['payment_method']['value_formatted'];
	
	/* see $order_formatted for all available parameters */

	return $subject;
}