WC_WCCOM_Site_Installation_State_Storage::get_state()public staticWC 1.0

Get state from storage.

Method of the class: WC_WCCOM_Site_Installation_State_Storage{}

No Hooks.

Return

WC_WCCOM_Site_Installation_State|null.

Usage

$result = WC_WCCOM_Site_Installation_State_Storage::get_state( $product_id ) : ?WC_WCCOM_Site_Installation_State;
$product_id(int) (required)
The product ID.

WC_WCCOM_Site_Installation_State_Storage::get_state() code WC 9.3.3

public static function get_state( $product_id ) : ?WC_WCCOM_Site_Installation_State {
	$storage_key = self::get_storage_key( $product_id );
	$data        = get_option( $storage_key );

	if ( ! is_array( $data ) ) {
		return null;
	}

	$installation_state = WC_WCCOM_Site_Installation_State::initiate_existing(
		$product_id,
		$data['idempotency_key'],
		$data['last_step_name'],
		$data['last_step_status'],
		$data['last_step_error'],
		$data['started_date']
	);

	$installation_state->set_product_type( $data['product_type'] ?? null );
	$installation_state->set_product_name( $data['product_name'] ?? null );
	$installation_state->set_download_url( $data['download_url'] ?? null );
	$installation_state->set_download_path( $data['download_path'] ?? null );
	$installation_state->set_unpacked_path( $data['unpacked_path'] ?? null );
	$installation_state->set_installed_path( $data['installed_path'] ?? null );
	$installation_state->set_already_installed_plugin_info( $data['already_installed_plugin_info'] ?? null );

	return $installation_state;
}