Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationPreferencesService::get_preferences
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.
Method of the class: NotificationPreferencesService{}
No Hooks.
Returns
Array
Usage
$NotificationPreferencesService = new NotificationPreferencesService(); $NotificationPreferencesService->get_preferences( $user_id ): array;
- $user_id(int) (required)
- The user ID.
Changelog
| Since 10.8.0 | Introduced. |
NotificationPreferencesService::get_preferences() NotificationPreferencesService::get preferences code WC 10.9.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 ) );
}