diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index e9570007aa1..9305ea76fbd 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -586,26 +586,19 @@ class WC_Admin_Post_Types { if ( $post->comment_count ) { - // check the status of the post - $status = ( 'trash' !== $post->post_status ) ? '' : 'post-trashed'; - - remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); - - $latest_notes = get_comments( array( - 'post_id' => $post->ID, - 'number' => 1, - 'status' => $status, + $latest_notes = wc_get_order_notes( array( + 'order_id' => $post->ID, + 'limit' => 1, + 'orderby' => 'date_created_gmt', ) ); - add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); - $latest_note = current( $latest_notes ); - if ( isset( $latest_note->comment_content ) && 1 == $post->comment_count ) { - echo '' . __( 'Yes', 'woocommerce' ) . ''; - } elseif ( isset( $latest_note->comment_content ) ) { + if ( isset( $latest_note->content ) && 1 == $post->comment_count ) { + echo '' . __( 'Yes', 'woocommerce' ) . ''; + } elseif ( isset( $latest_note->content ) ) { /* translators: %d: notes count */ - echo '' . sprintf( _n( 'plus %d other note', 'plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '' ) . '">' . __( 'Yes', 'woocommerce' ) . ''; + echo '' . sprintf( _n( 'Plus %d other note', 'Plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '' ) . '">' . __( 'Yes', 'woocommerce' ) . ''; } else { /* translators: %d: notes count */ echo '' . __( 'Yes', 'woocommerce' ) . ''; diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php b/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php index 4e269154c55..d3c62f85a56 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php @@ -26,18 +26,10 @@ class WC_Meta_Box_Order_Notes { global $post; $args = array( - 'post_id' => $post->ID, - 'orderby' => 'comment_ID', - 'order' => 'DESC', - 'approve' => 'approve', - 'type' => 'order_note', + 'order_id' => $post->ID, ); - remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); - - $notes = get_comments( $args ); - - add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + $notes = wc_get_order_notes( $args ); echo '