public static
getTotalPointsByUserIdExceptCurrentOrder
(mixed $userId, mixed $orderId)
// STATIC PART
public static function getTotalPointsByUserIdExceptCurrentOrder($userId, $orderId)
{
if ((int) $userId > 0 && (int) $orderId > 0) {
$db = Factory::getDBO();
$query = 'SELECT SUM(a.points) FROM #__phocacart_reward_points AS a' . ' WHERE a.user_id = ' . (int) $userId . ' AND a.order_id <> ' . (int) $orderId . ' AND a.published = 1' . ' GROUP BY a.order_id' . ' ORDER BY a.id';
$db->setQuery($query);
$total = $db->loadResult();
if (!$total) {
$total = 0;
}
return (int) $total;
}
return 0;
}