Automattic\WooCommerce\Internal\PushNotifications\Services
StepLogQuery::strip_unrelated_tokens
Returns the row for one token, with every other token's data removed.
The stored line names every token the notification touched, so the three token lists are dropped and the step and outcome are replaced with what happened to this one. Two rows built from the same line can therefore carry different outcomes.
Method of the class: StepLogQuery{}
No Hooks.
Returns
array.
Usage
$result = StepLogQuery::strip_unrelated_tokens( $row, $token_id, $step, $outcome ): array;
- $row(array) (required)
- The stored row.
- $token_id(int) (required)
- The token to keep.
- $step(string) (required)
- The step to report for that token.
- $outcome(string) (required)
- The outcome to report for that token.
StepLogQuery::strip_unrelated_tokens() StepLogQuery::strip unrelated tokens code WC 11.3.0
private static function strip_unrelated_tokens( array $row, int $token_id, string $step, string $outcome ): array {
$context = $row['context'] ?? array();
unset( $context['excluded_tokens'], $context['invalid_token_ids'], $context['token_ids'] );
$context['token_id'] = $token_id;
$context['step'] = $step;
$context['outcome'] = $outcome;
$row['context'] = $context;
$row['message'] = ucfirst( str_replace( '_', ' ', $step ) ) . ': ' . str_replace( '_', ' ', $outcome );
return $row;
}