WC_API_Orders::get_order_notes()
Get the admin order notes for an order
Метод класса: WC_API_Orders{}
Хуки из метода
Возвращает
Массив|WP_Error
.
Использование
$WC_API_Orders = new WC_API_Orders(); $WC_API_Orders->get_order_notes( $id, $fields );
- $id(int) (обязательный)
- the order ID
- $fields(строка)
- fields to include in response
По умолчанию: null
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Orders::get_order_notes() WC API Orders::get order notes WC 7.7.2
public function get_order_notes( $id, $fields = null ) { // ensure ID is valid order ID $id = $this->validate_request( $id, 'shop_order', 'read' ); if ( is_wp_error( $id ) ) { return $id; } $args = array( 'post_id' => $id, 'approve' => 'approve', 'type' => 'order_note', ); 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 ); $order_notes = array(); foreach ( $notes as $note ) { $order_notes[] = array( 'id' => $note->comment_ID, 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'note' => $note->comment_content, 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), ); } return array( 'order_notes' => apply_filters( 'woocommerce_api_order_notes_response', $order_notes, $id, $fields, $notes, $this->server ) ); }