WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API

Plugins::install_plugins() public WC 1.0

Installs the requested plugins.

{} It's a method of the class: Plugins{}

No Hooks.

Return

WP_Error|Array. Plugin Status

Usage

$Plugins = new Plugins();
$Plugins->install_plugins( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Code of Plugins::install_plugins() WC 5.2.2

<?php
public function install_plugins( $request ) {
	$allowed_plugins = self::get_allowed_plugins();
	$plugins         = explode( ',', $request['plugins'] );

	if ( empty( $request['plugins'] ) || ! is_array( $plugins ) ) {
		return new \WP_Error( 'woocommerce_rest_invalid_plugins', __( 'Plugins must be a non-empty array.', 'woocommerce' ), 404 );
	}

	require_once ABSPATH . 'wp-admin/includes/plugin.php';
	include_once ABSPATH . '/wp-admin/includes/admin.php';
	include_once ABSPATH . '/wp-admin/includes/plugin-install.php';
	include_once ABSPATH . '/wp-admin/includes/plugin.php';
	include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
	include_once ABSPATH . '/wp-admin/includes/class-plugin-upgrader.php';

	$existing_plugins  = get_plugins();
	$installed_plugins = array();
	$results           = array();
	$errors            = new \WP_Error();

	foreach ( $plugins as $plugin ) {
		$slug = sanitize_key( $plugin );
		$path = isset( $allowed_plugins[ $slug ] ) ? $allowed_plugins[ $slug ] : false;

		if ( ! $path ) {
			$errors->add(
				$plugin,
				/* translators: %s: plugin slug (example: woocommerce-services) */
				sprintf( __( 'The requested plugin `%s` is not in the list of allowed plugins.', 'woocommerce' ), $slug )
			);
			continue;
		}

		if ( in_array( $path, array_keys( $existing_plugins ), true ) ) {
			$installed_plugins[] = $plugin;
			continue;
		}

		$api = plugins_api(
			'plugin_information',
			array(
				'slug'   => $slug,
				'fields' => array(
					'sections' => false,
				),
			)
		);

		if ( is_wp_error( $api ) ) {
			$properties = array(
				/* translators: %s: plugin slug (example: woocommerce-services) */
				'error_message' => __( 'The requested plugin `%s` could not be installed. Plugin API call failed.', 'woocommerce' ),
				'api'           => $api,
				'slug'          => $slug,
			);
			wc_admin_record_tracks_event( 'install_plugin_error', $properties );

			$this->create_install_plugin_error_inbox_notification_for_jetpack_installs( $slug );

			$errors->add(
				$plugin,
				sprintf(
					/* translators: %s: plugin slug (example: woocommerce-services) */
					__( 'The requested plugin `%s` could not be installed. Plugin API call failed.', 'woocommerce' ),
					$slug
				)
			);

			continue;
		}

		$upgrader           = new \Plugin_Upgrader( new \Automatic_Upgrader_Skin() );
		$result             = $upgrader->install( $api->download_link );
		$results[ $plugin ] = $result;

		if ( is_wp_error( $result ) || is_null( $result ) ) {
			$properties = array(
				/* translators: %s: plugin slug (example: woocommerce-services) */
				'error_message' => __( 'The requested plugin `%s` could not be installed.', 'woocommerce' ),
				'slug'          => $slug,
				'api'           => $api,
				'upgrader'      => $upgrader,
				'result'        => $result,
			);
			wc_admin_record_tracks_event( 'install_plugin_error', $properties );

			$this->create_install_plugin_error_inbox_notification_for_jetpack_installs( $slug );

			$errors->add(
				$plugin,
				sprintf(
					/* translators: %s: plugin slug (example: woocommerce-services) */
					__( 'The requested plugin `%s` could not be installed.  Upgrader install failed.', 'woocommerce' ),
					$slug
				)
			);
			continue;
		}

		$installed_plugins[] = $plugin;
	}

	return array(
		'data'    => array(
			'installed' => $installed_plugins,
			'results'   => $results,
		),
		'errors'  => $errors,
		'success' => count( $errors->errors ) === 0,
		'message' => count( $errors->errors ) === 0
			? __( 'Plugins were successfully installed.', 'woocommerce' )
			: __( 'There was a problem installing some of the requested plugins.', 'woocommerce' ),
	);
}