WC_REST_Webhook_Deliveries_V1_Controller::get_item()publicWC 1.0

Get a single webhook delivery.

Метод класса: WC_REST_Webhook_Deliveries_V1_Controller{}

Хуков нет.

Возвращает

WP_Error|WP_REST_Response.

Использование

$WC_REST_Webhook_Deliveries_V1_Controller = new WC_REST_Webhook_Deliveries_V1_Controller();
$WC_REST_Webhook_Deliveries_V1_Controller->get_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код WC_REST_Webhook_Deliveries_V1_Controller::get_item() WC 9.3.3

public function get_item( $request ) {
	$id      = (int) $request['id'];
	$webhook = wc_get_webhook( (int) $request['webhook_id'] );

	if ( empty( $webhook ) || is_null( $webhook ) ) {
		return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	$log = array();

	if ( empty( $id ) || empty( $log ) ) {
		return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	$delivery = $this->prepare_item_for_response( (object) $log, $request );
	$response = rest_ensure_response( $delivery );

	return $response;
}