【发布时间】:2018-05-17 12:49:22
【问题描述】:
我正在编写一个插件,客户可以使用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!";
}
【问题讨论】:
标签: wordpress woocommerce