WC_REST_Shipping_Methods_V2_Controller::get_item()
Get a single Shipping Method.
Метод класса: WC_REST_Shipping_Methods_V2_Controller{}
Хуков нет.
Возвращает
WP_REST_Response|WP_Error
.
Использование
$WC_REST_Shipping_Methods_V2_Controller = new WC_REST_Shipping_Methods_V2_Controller(); $WC_REST_Shipping_Methods_V2_Controller->get_item( $request );
- $request(WP_REST_Request) (обязательный)
- Request data.
Код WC_REST_Shipping_Methods_V2_Controller::get_item() WC REST Shipping Methods V2 Controller::get item WC 8.7.0
public function get_item( $request ) { $wc_shipping = WC_Shipping::instance(); $methods = $wc_shipping->get_shipping_methods(); if ( empty( $methods[ $request['id'] ] ) ) { return new WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); } $method = $methods[ $request['id'] ]; $response = $this->prepare_item_for_response( $method, $request ); return rest_ensure_response( $response ); }