0

Add a message or notes to order emails (WooCommerce)

Sometimes it comes in handy to be able to give information to your customers in the emails they receive. It can be info on where to download extra files, like manuals or consumer right documents. Or any other instructions or promotional text, like a coupon code to get them to buy again, or reminders if they have to take some kind of action after the purchase.

Insert the code below to your functions.php and edit the text to fit the emails you send to your customer after they order a product or service. The message will appear in all order emails.

(We also have a plugin for you if you don’t want to use code snippets in your themes, please see this: Add a message or notes to order emails )

  • Change ‘Order Notes’ to whatever you want.
  • Then change ‘There are no notes for this order yet.’ to the message or note your customer should get. You can use text or links.




<?php
add_action( 'woocommerce_email_order_meta', 'woo_add_order_notes_to_email' );
function woo_add_order_notes_to_email() {
	global $woocommerce, $post;
	$args = array(
		'post_id' 	=> $post->ID,
		'approve' 	=> 'approve',
		'type' 		=> 'order_note'
	);
	$notes = get_comments( $args );
	
	echo '<h2>' . __( 'Order Notes', 'woocommerce' ) . '</h2>';
	echo '<ul class="order_notes">';
	if ( $notes ) {
		foreach( $notes as $note ) {
			$note_classes = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? array( 'customer-note', 'note' ) : array( 'note' );
			?>
			<li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo implode( ' ', $note_classes ); ?>">
				<div class="note_content">
					(<?php printf( __( 'added %s ago', 'woocommerce' ), human_time_diff( strtotime( $note->comment_date_gmt ), current_time( 'timestamp', 1 ) ) ); ?>) <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
				</div>
			</li>
			<?php
		}
	} else {
		echo '<li>' . __( 'There are no notes for this order yet.', 'woocommerce' ) . '</li>';
	}
	echo '</ul>';

The result can be something like this: