WC_REST_Terms_Controller::get_item()publicWC 1.0

Get a single term from a taxonomy.

Метод класса: WC_REST_Terms_Controller{}

Хуков нет.

Возвращает

WP_REST_Request|WP_Error.

Использование

$WC_REST_Terms_Controller = new WC_REST_Terms_Controller();
$WC_REST_Terms_Controller->get_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код WC_REST_Terms_Controller::get_item() WC 7.1.0

public function get_item( $request ) {
	$taxonomy = $this->get_taxonomy( $request );
	$term     = get_term( (int) $request['id'], $taxonomy );

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

	$response = $this->prepare_item_for_response( $term, $request );

	return rest_ensure_response( $response );
}