Automattic\WooCommerce\Internal\PushNotifications\Controllers

NotificationPreferencesRestController::update_preferencespublicWC 10.8.0

Partially update the current user's notification preferences and return the merged result.

Method of the class: NotificationPreferencesRestController{}

No Hooks.

Returns

WP_REST_Response|WP_Error.

Usage

$NotificationPreferencesRestController = new NotificationPreferencesRestController();
$NotificationPreferencesRestController->update_preferences( $request );
$request(WP_REST_Request) (required)
The request object.

Changelog

Since 10.8.0 Introduced.

NotificationPreferencesRestController::update_preferences() code WC 10.9.1

public function update_preferences( WP_REST_Request $request ) {
	try {
		$merged = $this->preferences_service->save_preferences(
			get_current_user_id(),
			$request->get_params()
		);
	} catch ( Exception $e ) {
		return $this->convert_exception_to_wp_error( $e );
	}

	return new WP_REST_Response( $merged, WP_Http::OK );
}