Flag Orders That Have a Customer Note
Adds a narrow column to the admin orders list with an icon on orders where the customer left a note, and shows the note when you hover over it.
Opens WPIDE on
Code
$wpide_note_column = function ( $columns ) {
$new = array();
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
if ( 'order_number' === $key ) {
$new['wpide_note'] = '<span class="dashicons dashicons-format-chat" title="Customer note"></span><span class="screen-reader-text">Customer note</span>';
}
}
return $new;
};
$wpide_note_render = function ( $column, $order ) {
if ( 'wpide_note' !== $column ) {
return;
}
$order = $order instanceof WC_Order ? $order : wc_get_order( $order );
$note = $order ? trim( (string) $order->get_customer_note() ) : '';
if ( '' !== $note ) {
printf( '<span class="dashicons dashicons-format-chat" style="color:#d63638" title="%1$s"></span><span class="screen-reader-text">%2$s</span>', esc_attr( $note ), esc_html( $note ) );
}
};
add_filter( 'manage_woocommerce_page_wc-orders_columns', $wpide_note_column );
add_filter( 'manage_edit-shop_order_columns', $wpide_note_column );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', $wpide_note_render, 10, 2 );
add_action( 'manage_shop_order_posts_custom_column', $wpide_note_render, 10, 2 );
add_action( 'admin_head', function () {
echo '<style>.column-wpide_note{width:2.5em;text-align:center}</style>';
} );
Notes
Helps you spot delivery instructions and gift messages before packing.
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.