WC_WCCOM_Site_Installation_State_Storage::get_state()public staticWC 1.0

Get state from storage.

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

Хуков нет.

Возвращает

WC_WCCOM_Site_Installation_State|null.

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

$result = WC_WCCOM_Site_Installation_State_Storage::get_state( $product_id ) : ?WC_WCCOM_Site_Installation_State;
$product_id(int) (обязательный)
The product ID.

Код WC_WCCOM_Site_Installation_State_Storage::get_state() WC 9.4.2

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;
}