WC_REST_Tax_Classes_V2_Controller::get_item()
Get one tax class.
Метод класса: WC_REST_Tax_Classes_V2_Controller{}
Хуков нет.
Возвращает
Массив
.
Использование
$WC_REST_Tax_Classes_V2_Controller = new WC_REST_Tax_Classes_V2_Controller(); $WC_REST_Tax_Classes_V2_Controller->get_item( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_REST_Tax_Classes_V2_Controller::get_item() WC REST Tax Classes V2 Controller::get item WC 9.3.3
public function get_item( $request ) { if ( 'standard' === $request['slug'] ) { $tax_class = array( 'slug' => 'standard', 'name' => __( 'Standard rate', 'woocommerce' ), ); } else { $tax_class = WC_Tax::get_tax_class_by( 'slug', sanitize_title( $request['slug'] ) ); } if ( ! $tax_class ) { return new WP_Error( 'woocommerce_rest_tax_class_invalid_slug', __( 'Invalid slug.', 'woocommerce' ), array( 'status' => 404 ) ); } $data = array(); $class = $this->prepare_item_for_response( $tax_class, $request ); $class = $this->prepare_response_for_collection( $class ); $data[] = $class; return rest_ensure_response( $data ); }