Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationPreferencesService::get_defaults
Return the default preferences for a new user.
Each preference is a small object so future fields (thresholds, sub-toggles) can be added without bumping the schema version. The keyset is derived from Notification::NOTIFICATION_CLASSES so adding a new notification type automatically opts it into preferences — no parallel list to keep in sync.
Method of the class: NotificationPreferencesService{}
No Hooks.
Returns
Array
Usage
$NotificationPreferencesService = new NotificationPreferencesService(); $NotificationPreferencesService->get_defaults(): array;
Changelog
| Since 10.8.0 | Introduced. |
NotificationPreferencesService::get_defaults() NotificationPreferencesService::get defaults code WC 10.9.1
public function get_defaults(): array {
$defaults = array();
foreach ( array_keys( Notification::NOTIFICATION_CLASSES ) as $type ) {
$defaults[ $type ] = array( 'enabled' => true );
}
$defaults['store_order']['min_amount'] = null;
$defaults['store_review']['max_rating'] = null;
$defaults['store_stock']['low_stock'] = true;
$defaults['store_stock']['out_of_stock'] = true;
$defaults['store_stock']['on_backorder'] = true;
return $defaults;
}