Highlight the Customer's Order Note in Admin Emails
Shows the note the customer wrote at checkout in a highlighted box at the top of the admin "New order" email, so special requests are not missed.
Opens WPIDE on
Code
add_action( 'woocommerce_email_before_order_table', function ( $order, $sent_to_admin, $plain_text ) {
if ( ! $sent_to_admin || ! $order instanceof WC_Order ) {
return;
}
$note = $order->get_customer_note();
if ( '' === trim( $note ) ) {
return;
}
if ( $plain_text ) {
echo "CUSTOMER NOTE:\n" . esc_html( $note ) . "\n\n";
return;
}
echo '<div style="margin:0 0 20px;padding:12px 16px;border-left:4px solid #dba617;background:#fcf9e8;"><strong>Customer note:</strong><br>' . nl2br( esc_html( $note ) ) . '</div>';
}, 5, 3 );
Notes
Only appears when the customer left a note.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.