Automattic\WooCommerce\Internal\RestApi\Routes\V4\OrderNotes\Schema

OrderNoteSchema::get_item_responsepublicWC 1.0

Get the item response.

Method of the class: OrderNoteSchema{}

No Hooks.

Returns

Array. The item response.

Usage

$OrderNoteSchema = new OrderNoteSchema();
$OrderNoteSchema->get_item_response( $note, $request, $include_fields ): array;
$note(WP_Comment) (required)
Order note object.
$request(WP_REST_Request) (required)
Request object.
$include_fields(array)
Fields to include in the response.
Default: array()

OrderNoteSchema::get_item_response() code WC 10.4.3

public function get_item_response( $note, WP_REST_Request $request, array $include_fields = array() ): array {
	$group            = get_comment_meta( $note->comment_ID, 'note_group', true );
	$title            = get_comment_meta( $note->comment_ID, 'note_title', true );
	$is_customer_note = wc_string_to_bool( get_comment_meta( $note->comment_ID, 'is_customer_note', true ) );

	if ( $group && ! $title ) {
		$title = OrderNoteGroup::get_default_group_title( $group );
	}

	return array(
		'id'               => (int) $note->comment_ID,
		'order_id'         => (int) $note->comment_post_ID,
		'author'           => $note->comment_author,
		'date_created'     => wc_rest_prepare_date_response( $note->comment_date ),
		'date_created_gmt' => wc_rest_prepare_date_response( $note->comment_date_gmt ),
		'note'             => $note->comment_content,
		'title'            => $title,
		'group'            => $group,
		'is_customer_note' => $is_customer_note,
	);
}