WC_REST_Payment_Gateways_V2_Controller::prepare_item_for_response()
Prepare a payment gateway for response.
Метод класса: WC_REST_Payment_Gateways_V2_Controller{}
Хуки из метода
Возвращает
WP_REST_Response
. $response Response data.
Использование
$WC_REST_Payment_Gateways_V2_Controller = new WC_REST_Payment_Gateways_V2_Controller(); $WC_REST_Payment_Gateways_V2_Controller->prepare_item_for_response( $gateway, $request );
- $gateway(WC_Payment_Gateway) (обязательный)
- Payment gateway object.
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_REST_Payment_Gateways_V2_Controller::prepare_item_for_response() WC REST Payment Gateways V2 Controller::prepare item for response WC 9.3.3
public function prepare_item_for_response( $gateway, $request ) { $order = (array) get_option( 'woocommerce_gateway_order' ); $item = array( 'id' => $gateway->id, 'title' => $gateway->title, 'description' => $gateway->description, 'order' => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '', 'enabled' => ( 'yes' === $gateway->enabled ), 'method_title' => $gateway->get_method_title(), 'method_description' => $gateway->get_method_description(), 'settings' => $this->get_settings( $gateway ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $item, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $gateway, $request ) ); /** * Filter payment gateway objects returned from the REST API. * * @param WP_REST_Response $response The response object. * @param WC_Payment_Gateway $gateway Payment gateway object. * @param WP_REST_Request $request Request object. */ return apply_filters( 'woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request ); }