wc_get_order_note()WC 3.2.0

Get an order note.

Hooks from the function

Return

stdClass|null. Object with order note details or null when does not exists.

Usage

wc_get_order_note( $data );
$data(int|WP_Comment) (required)
Note ID (or WP_Comment instance for internal use only).

Changelog

Since 3.2.0 Introduced.

wc_get_order_note() code WC 9.4.2

function wc_get_order_note( $data ) {
	if ( is_numeric( $data ) ) {
		$data = get_comment( $data );
	}

	if ( ! is_a( $data, 'WP_Comment' ) ) {
		return null;
	}

	return (object) apply_filters(
		'woocommerce_get_order_note',
		array(
			'id'            => (int) $data->comment_ID,
			'date_created'  => wc_string_to_datetime( $data->comment_date ),
			'content'       => $data->comment_content,
			'customer_note' => (bool) get_comment_meta( $data->comment_ID, 'is_customer_note', true ),
			'added_by'      => __( 'WooCommerce', 'woocommerce' ) === $data->comment_author ? 'system' : $data->comment_author,
			'order_id'      => absint( $data->comment_post_ID ),
		),
		$data
	);
}