Automattic\WooCommerce\Internal\PushNotifications\Services

PendingNotificationStore::addpublicWC 10.7.0

Adds a notification to the pending store.

Duplicate notifications (same type and resource ID) within a single request are silently ignored. The shutdown hook is registered on the first call.

Method of the class: PendingNotificationStore{}

No Hooks.

Returns

null. Nothing (null).

Usage

$PendingNotificationStore = new PendingNotificationStore();
$PendingNotificationStore->add( $notification ): void;
$notification(Notification) (required)
The notification to add.

Changelog

Since 10.7.0 Introduced.

PendingNotificationStore::add() code WC 11.0.1

public function add( Notification $notification ): void {
	if ( ! $this->enabled ) {
		return;
	}

	$key = $notification->get_identifier();

	if ( isset( $this->pending[ $key ] ) ) {
		return;
	}

	$this->pending[ $key ] = $notification;

	$this->schedule_safety_net( $notification );

	if ( ! $this->shutdown_registered ) {
		add_action( 'shutdown', array( $this, 'dispatch_all' ) );
		$this->shutdown_registered = true;
	}
}