Docly Child

How to add custom message to the order processing email

You can use the following code snippet in your theme’s functions.php file to add a custom message before the order table in the processing order email:

/*
* add custom message in before order table in the processing order emails
*/
add_action( 'woocommerce_email_before_order_table', 'add_custom_message_before_order_table', 10, 4 );

function add_custom_message_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {		

	// Iterating through order shipping items
	foreach ( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ) {			
		$shipping_method = $shipping_item_obj->get_method_id();						
	}
	
	//IF  dshipping method is not local pickup then @return;
	if ( !isset($shipping_method ) ) {
		return;
	}
	if ( isset($shipping_method ) && 'local_pickup' != $shipping_method ) {
		return;		
	}
	
	if ( 'customer_processing_order' != $email->id ) {
		return;
	}
	
	// add additional content in email
	echo '<p>' . wp_kses_post("You will receive an email when your order is ready for pickup. This will also include the pickup address. Please do not arrive to pick up your order until you have been notified it's ready.") . '</p>';
	
}

$129.00

Billed annually

Buy Now