WC_REST_WCCOM_Site_Installer_Controller::get_product_install_statepublicWC 3.7.0

Get installation state.

Method of the class: WC_REST_WCCOM_Site_Installer_Controller{}

No Hooks.

Returns

true|false|WP_Error.

Usage

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

Changelog

Since 3.7.0 Introduced.

WC_REST_WCCOM_Site_Installer_Controller::get_product_install_state() code WC 10.6.2

public function get_product_install_state( $request ) {
	$product_id = (int) $request->get_param( 'product_id' );
	if ( $product_id <= 0 ) {
		return rest_ensure_response(
			new WP_Error(
				'missing_param',
				'The product_id parameter is required.',
				array( 'status' => 400 )
			)
		);
	}

	$installation_manager = new WC_WCCOM_Site_Installation_Manager( $product_id );

	try {
		$state = $installation_manager->get_installation_status();
		return $this->success_response( $product_id, $state );
	} catch ( Installer_Error $exception ) {
		return $this->failure_response( $product_id, $exception );
	}
}