WC_REST_Taxes_V1_Controller::get_item()
Get a single tax.
Метод класса: WC_REST_Taxes_V1_Controller{}
Хуков нет.
Возвращает
WP_Error|WP_REST_Response
.
Использование
$WC_REST_Taxes_V1_Controller = new WC_REST_Taxes_V1_Controller(); $WC_REST_Taxes_V1_Controller->get_item( $request );
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Код WC_REST_Taxes_V1_Controller::get_item() WC REST Taxes V1 Controller::get item WC 8.7.0
public function get_item( $request ) { $id = (int) $request['id']; $tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT ); if ( empty( $id ) || empty( $tax_obj ) ) { return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); } $tax = $this->prepare_item_for_response( $tax_obj, $request ); $response = rest_ensure_response( $tax ); return $response; }