Automattic\WooCommerce\Blocks\StoreApi\Routes
ProductCategoriesById::get_route_response() protected WC 1.0
Get a single item.
{} Это метод класса: ProductCategoriesById{}
Хуков нет.
Возвращает
\WP_REST_Response
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_route_response( \WP_REST_Request $request );
- \WP_REST_Request $request (обязательный)
- -
Код ProductCategoriesById::get_route_response() ProductCategoriesById::get route response WC 5.2.2
protected function get_route_response( \WP_REST_Request $request ) {
$object = get_term( (int) $request['id'], 'product_cat' );
if ( ! $object || 0 === $object->id ) {
throw new RouteException( 'woocommerce_rest_category_invalid_id', __( 'Invalid category ID.', 'woocommerce' ), 404 );
}
$data = $this->prepare_item_for_response( $object, $request );
return rest_ensure_response( $data );
}