Automattic\WooCommerce\Internal\StockNotifications\Frontend

MyAccountEndpoint::get_current_user_pending_notifications │ public │ WC 1.0

Return the current user's pending (awaiting confirmation) notifications, newest first.

Always scopes to get_current_user_id() the caller is never trusted.

Метод класса: MyAccountEndpoint{}

Хуков нет.

Возвращает

array<Notification>.

Использование

$MyAccountEndpoint = new MyAccountEndpoint();
$MyAccountEndpoint->get_current_user_pending_notifications( $limit ): array;
$limit(int) (обязательный)
Maximum number of notifications to return.

Код MyAccountEndpoint::get_current_user_pending_notifications() WC 11.2.2

public function get_current_user_pending_notifications( int $limit ): array {
	$limit = max( 1, $limit );

	$user_id = get_current_user_id();
	if ( $user_id <= 0 ) {
		return array();
	}

	return NotificationQuery::get_notifications(
		array(
			'user_id'  => $user_id,
			'status'   => NotificationStatus::PENDING,
			'order_by' => array( 'id' => 'DESC' ),
			'return'   => 'objects',
			'limit'    => $limit,
		)
	);
}