Automattic\WooCommerce\Admin\API
Notes::get_item
Get a single note.
Method of the class: Notes{}
No Hooks.
Returns
WP_REST_Response|WP_Error.
Usage
$Notes = new Notes(); $Notes->get_item( $request );
- $request(WP_REST_Request) (required)
- Request data.
Notes::get_item() Notes::get item code WC 10.8.1
public function get_item( $request ) {
$note = NotesRepository::get_note( $request->get_param( 'id' ) );
if ( ! $note ) {
return new \WP_Error(
'woocommerce_note_invalid_id',
__( 'Sorry, there is no resource with that ID.', 'woocommerce' ),
array( 'status' => 404 )
);
}
if ( is_wp_error( $note ) ) {
return $note;
}
$data = $this->prepare_note_data_for_response( $note, $request );
return rest_ensure_response( $data );
}