Automattic\WooCommerce\Internal\Admin

WcPayWelcomePage::generate_context_hash()privateWC 1.0

Generate a hash from the store context data.

Method of the class: WcPayWelcomePage{}

No Hooks.

Return

String. The context hash.

Usage

// private - for code of main (parent) class only
$result = $this->generate_context_hash( $context ): string;
$context(array) (required)
The store context data.

WcPayWelcomePage::generate_context_hash() code WC 9.3.3

private function generate_context_hash( array $context ): string {
	// Include only certain entries in the context hash.
	// We need only discrete, user-interaction dependent data.
	// Entries like `active_for` have no place in the hash generation since they change automatically.
	return md5(
		wp_json_encode(
			[
				'country'      => $context['country'] ?? '',
				'locale'       => $context['locale'] ?? '',
				'has_orders'   => $context['has_orders'] ?? false,
				'has_payments' => $context['has_payments'] ?? false,
				'has_wcpay'    => $context['has_wcpay'] ?? false,
			]
		)
	);
}