Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationPreferencesService::save_preferences
Persist a partial update to a user's notification preferences.
Unknown top-level keys and unknown sub-fields per key are dropped. The merged result is wrapped in the current versioned envelope and handed to the data store.
Метод класса: NotificationPreferencesService{}
Хуков нет.
Возвращает
array<string,. array<string, mixed>> The merged, sanitized preferences map after the save.
Использование
$NotificationPreferencesService = new NotificationPreferencesService(); $NotificationPreferencesService->save_preferences( $user_id, $preferences ): array;
- $user_id(int) (обязательный)
- The user ID.
- $preferences(массив) (обязательный)
- .
Список изменений
| С версии 10.8.0 | Введена. |
Код NotificationPreferencesService::save_preferences() NotificationPreferencesService::save preferences WC 11.3.0
public function save_preferences( int $user_id, array $preferences ): array {
$current = $this->get_preferences( $user_id );
$merged = $this->sanitize( array_replace_recursive( $current, $preferences ) );
// Data store throws WC_Data_Exception on real failure; let it propagate.
$this->data_store->write(
$user_id,
array(
'schema_version' => NotificationPreferencesDataStore::CURRENT_SCHEMA_VERSION,
'preferences' => $merged,
)
);
return $merged;
}