Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationProcessor::log_excluded_tokens
Writes one line naming every token the notification was not sent to, grouped by the reason each was excluded.
Grouping by reason rather than naming a reason per token keeps the line small on a store where most tokens are excluded.
Method of the class: NotificationProcessor{}
No Hooks.
Returns
void. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->log_excluded_tokens( $notification, $suppression_reasons, $step_context ): void;
- $notification(Notification) (required)
- The notification being processed.
- $suppression_reasons(array<int, string>) (required)
- The reason each dropped token was excluded, as token ID => reason.
- $step_context(array) (required)
- Fields shared by every line of this attempt.
NotificationProcessor::log_excluded_tokens() NotificationProcessor::log excluded tokens code WC 11.3.0
private function log_excluded_tokens( Notification $notification, array $suppression_reasons, array $step_context ): void {
if ( empty( $suppression_reasons ) ) {
return;
}
$by_reason = array();
foreach ( $suppression_reasons as $token_id => $reason ) {
$by_reason[ $reason ][] = (int) $token_id;
}
$outcome = 'various';
if ( 1 === count( $by_reason ) ) {
$outcome = (string) array_key_first( $by_reason );
}
$this->step_logger->log_suppressed_step(
$notification,
'token_excluded',
$outcome,
array_merge( $step_context, array( 'excluded_tokens' => $by_reason ) )
);
}