Skip to content

Instantly share code, notes, and snippets.

@rwkyyy
Created December 13, 2022 14:05
Show Gist options
  • Save rwkyyy/e29c49b899c64a882f8673517907d4c8 to your computer and use it in GitHub Desktop.
Save rwkyyy/e29c49b899c64a882f8673517907d4c8 to your computer and use it in GitHub Desktop.
order notes existance indicator in listing - woocommerce
function rwk_order_notes_column( $columns ) {
$ordered_columns = array();
foreach ( $columns as $key => $column ) {
$ordered_columns[ $key ] = $column;
if ( 'order_date' == $key ) {
$ordered_columns['order_notes'] = __( 'Order notes', 'woocommerce' );
}
}
return $ordered_columns;
}
add_filter( 'manage_edit-shop_order_columns', 'rwk_order_notes_column', 10, 1 );
function rwk_order_notes_checker( $column, $post_id ) {
// Get $order object
$order = wc_get_order( $post_id );
if ( $column == 'order_notes' ) {
if ( $order->get_customer_note() ) {
echo '<strong style="color:green !important; font-size:15px !important;"><span class="dashicons dashicons-yes"></span></strong>';
} else {
echo '<strong style="color:red !important; font-size:15px !important;"><span class="dashicons dashicons-no-alt"></span></strong>';
}
}
}
add_action( 'manage_shop_order_posts_custom_column', 'custom_shop_order_list_column_content', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment