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.

Method of the class: MyAccountEndpoint{}

No Hooks.

Returns

array<Notification>.

Usage

$MyAccountEndpoint = new MyAccountEndpoint();
$MyAccountEndpoint->get_current_user_pending_notifications( $limit ): array;
$limit(int) (required)
Maximum number of notifications to return.

MyAccountEndpoint::get_current_user_pending_notifications() code WC 11.3.0

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,
		)
	);
}