WordPress at Your Fingertips
function is not described

WC_API_Orders::get_order_note() public WC 2.2

Get an order note for the given order ID and ID

{} It's a method of the class: WC_API_Orders{}

Hooks from the method
Return

Array|WP_Error.

Usage

$WC_API_Orders = new WC_API_Orders();
$WC_API_Orders->get_order_note( $order_id, $id, $fields );
$order_id(string) (required)
order ID
$id(string) (required)
order note ID
$fields(string|null)
fields to limit response to
Default: null

Changelog

Since 2.2 Introduced.

Code of WC_API_Orders::get_order_note() WC 5.7.1

public function get_order_note( $order_id, $id, $fields = null ) {
	try {
		// Validate order ID
		$order_id = $this->validate_request( $order_id, $this->post_type, 'read' );

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

		$id = absint( $id );

		if ( empty( $id ) ) {
			throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 );
		}

		$note = get_comment( $id );

		if ( is_null( $note ) ) {
			throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 );
		}

		$order_note = 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_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) );
	} catch ( WC_API_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}
}