WC_API_Orders::get_order_notes()publicWC 2.1

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( $order_id, $fields );
$order_id(строка) (обязательный)
order ID
$fields(строка|null)
fields to include in response
По умолчанию: null

Список изменений

С версии 2.1 Введена.

Код WC_API_Orders::get_order_notes() WC 8.9.3

public function get_order_notes( $order_id, $fields = null ) {

	// ensure ID is valid order ID
	$order_id = $this->validate_request( $order_id, $this->post_type, 'read' );

	if ( is_wp_error( $order_id ) ) {
		return $order_id;
	}

	$args = array(
		'post_id' => $order_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[] = current( $this->get_order_note( $order_id, $note->comment_ID, $fields ) );
	}

	return array( 'order_notes' => apply_filters( 'woocommerce_api_order_notes_response', $order_notes, $order_id, $fields, $notes, $this->server ) );
}