Automattic\WooCommerce\Internal\PushNotifications\Services

NotificationPreferencesService::get_preferencespublicWC 10.8.0

Retrieve a user's notification preferences.

Falls back to defaults for users with no stored preferences. Stored preferences are overlaid on top of the defaults so that any newer keys not yet on disk are filled in.

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

Хуков нет.

Возвращает

Массив<Строку,. array<string, mixed>> Map of preference key => sub-options.

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

$NotificationPreferencesService = new NotificationPreferencesService();
$NotificationPreferencesService->get_preferences( $user_id ): array;
$user_id(int) (обязательный)
The user ID.

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

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

Код NotificationPreferencesService::get_preferences() WC 11.0.1

public function get_preferences( int $user_id ): array {
	$envelope = $this->data_store->read( $user_id );

	if ( null === $envelope ) {
		return $this->get_defaults();
	}

	$stored = isset( $envelope['preferences'] ) && is_array( $envelope['preferences'] )
		? $envelope['preferences']
		: array();

	return $this->sanitize( array_replace_recursive( $this->get_defaults(), $stored ) );
}