How does WooCommerce display a custom comment_type in Comment Admin?

To answer your first question: »How does WooCommerce add the comment_type of order_note to the dropdown in Comment Administration?«. From woocommerce-admin-init.php:

function woocommerce_admin_comment_types_dropdown( $types ) {
    $types['order_note'] = __( 'Order notes', 'woocommerce' );
    return $types;
}

add_filter( 'admin_comment_types_dropdown', 'woocommerce_admin_comment_types_dropdown' );

Of course you have to do your own, to avoid conflicts, like this:

add_filter( 'admin_comment_types_dropdown', 'wpse114725_admin_comment_types_dropdown' );
function wpse114725_admin_comment_types_dropdown( $types ) {
    //replace the 'your...'-parts as needed
    $types['your_note_type'] = __( 'Your Note Type', 'your-text-domain' );
    return $types;
}

Regarding your second, previous question: »Where should I be looking for a guide/example on how to do this?«. From the looks of it you can get a pretty good example out of the woocommerce files.

Besides that the functions you need are all documented, for example: wp_insert_comment, wp_update_comment and wp_delete_comment. It’s maybe not the most comprehensive part of the codex, but the important information is there, of course you can always look in the source: wp-includes/comment.php.

From what you wrote I’m assuming you know your way with comment meta, i.e. add_comment_meta(), get_comment_meta(), update_comment_meta() and delete_comment_meta() – you can also find those in the codex, the source file is the same as linked above.

Because you haven’t posted a real problem to solve, I’d say that’s just about it – of course that’s not it at all, but this should get you a good overview where to start.

You might want to take a look at @brasofilo’s answer to How to add filter in “Comments” at the admin panel?, for more information and some additional keywords to guide you.

Leave a Comment