WordPress at Your Fingertips
function is not described

WC_REST_Posts_Controller::get_item() public WC 1.0

Get a single item.

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

No Hooks.

Return

WP_Error|WP_REST_Response.

Usage

$WC_REST_Posts_Controller = new WC_REST_Posts_Controller();
$WC_REST_Posts_Controller->get_item( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Code of WC_REST_Posts_Controller::get_item() WC 5.9.0

public function get_item( $request ) {
	$id   = (int) $request['id'];
	$post = get_post( $id );

	if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) {
		return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
	} elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) {
		return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	$data = $this->prepare_item_for_response( $post, $request );
	$response = rest_ensure_response( $data );

	if ( $this->public ) {
		$response->link_header( 'alternate', get_permalink( $id ), array( 'type' => 'text/html' ) );
	}

	return $response;
}