Automattic\WooCommerce\Internal\PushNotifications\Services
PendingNotificationStore::sort_with_new_orders_first
Moves new order notifications to the front of the batch.
Android only plays a sound for the first notification of a burst, and stock is reduced before the order notification is queued, so the order must go first for its sound to play.
Method of the class: PendingNotificationStore{}
No Hooks.
Returns
Notification[].
Usage
// private - for code of main (parent) class only $result = $this->sort_with_new_orders_first( $notifications ): array;
- $notifications(Notification[]) (required)
- The notifications about to be dispatched.
Changelog
| Since 11.3.0 | Introduced. |
PendingNotificationStore::sort_with_new_orders_first() PendingNotificationStore::sort with new orders first code WC 11.3.0
private function sort_with_new_orders_first( array $notifications ): array {
$new_orders = array();
$others = array();
foreach ( $notifications as $notification ) {
if ( NewOrderNotification::TYPE === $notification->get_type() ) {
$new_orders[] = $notification;
} else {
$others[] = $notification;
}
}
return array_merge( $new_orders, $others );
}