Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created November 17, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/730a34b4d29449446d4379b9caadee22 to your computer and use it in GitHub Desktop.
Save kellenmace/730a34b4d29449446d4379b9caadee22 to your computer and use it in GitHub Desktop.
Get All WooCommerce Order Notes
<?php
/**
* Get all approved WooCommerce order notes.
*
* @param int|string $order_id The order ID.
* @return array $notes The order notes, or an empty array if none.
*/
function km_get_order_notes( $order_id ) {
remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) );
$comments = get_comments( array(
'post_id' => $order_id,
'orderby' => 'comment_ID',
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note',
) );
$notes = wp_list_pluck( $comments, 'comment_content' );
add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) );
return $notes;
}
@EliMariaaaa
Copy link

Hi!

Your work is amazing. How can I show all the data - same with what we see on the right side of the Edit Order page?

When I simply use the class WC_Meta_Box_Order_Notes, it's showing as empty.

Thanks!
Eli
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment