WC_REST_WCCOM_Site_Installer_Controller::get_product_install_state │ public │ WC 3.7.0

Get installation state.

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

Хуков нет.

Возвращает

bool|WP_Error.

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

$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) (обязательный)
Full details about the request.

Список изменений

С версии 3.7.0 Введена.

Код WC_REST_WCCOM_Site_Installer_Controller::get_product_install_state() WC 11.2.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 );
	}
}