Я пишу плагин, чтобы клиент мог отслеживать статус / детали заказа с помощью order id
.
, а также я хочу показать только Примечания общественного порядка для клиента.
но я не могу найти какую-либо функцию или способ сделать это.
вот мой код, но этот код показывает все заметки, включая личные и публичные заметки:
*/
function woohez_get_all_order_notes( $order_id ){
$order_notes = array();
$args = array (
'post_id' => $order_id,
'orderby' => 'comment_ID',
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note'
);
remove_filter ( 'comments_clauses', array (
'WC_Comments',
'exclude_order_comments'
), 10, 1 );
$notes = get_comments ( $args );
if ($notes) {
foreach ( $notes as $note ) {
$order_notes[] = wpautop ( wptexturize ( wp_kses_post ( $note->comment_content ) ) );
}
}
return $order_notes;
}
$notes_array = woohez_get_all_order_notes( 209 );
if ( count( $notes_array ) != 0) {
foreach ( $notes_array as $notes ){
echo $notes;
}
} else {
echo "No notes found!";
}