Automattic\WooCommerce\Internal\Orders

OrderActionsRestController::check_permissions()privateWC 1.0

Permission check for REST API endpoint.

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

Хуков нет.

Возвращает

true|false|WP_Error. True if the current user has the capability, otherwise a WP_Error object.

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

// private - только в коде основоного (родительского) класса
$result = $this->check_permissions( $request );
$request(WP_REST_Request) (обязательный)
The request for which the permission is checked.

Код OrderActionsRestController::check_permissions() WC 9.5.1

private function check_permissions( WP_REST_Request $request ) {
	$order_id = $request->get_param( 'id' );
	$order    = wc_get_order( $order_id );

	if ( ! $order ) {
		return new WP_Error( 'woocommerce_rest_not_found', __( 'Order not found', 'woocommerce' ), array( 'status' => 404 ) );
	}

	return $this->check_permission( $request, 'read_shop_order', $order_id );
}