Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
WooPayments::generate_context_hash
Generate a hash from the store context data.
Method of the class: WooPayments{}
No Hooks.
Returns
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.
WooPayments::generate_context_hash() WooPayments::generate context hash code WC 10.5.0
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(
array(
'country' => $context['country'] ?? '',
'locale' => $context['locale'] ?? '',
'has_orders' => $context['has_orders'] ?? false,
'has_payments' => $context['has_payments'] ?? false,
'has_wcpay' => $context['has_wcpay'] ?? false,
)
)
);
}