public static function getUserOrderSum($userId)
{
$total = 0;
if ($userId > 0) {
$db = Factory::getDBO();
$query = 'SELECT SUM(a.amount) FROM #__phocacart_order_total AS a' . ' LEFT JOIN #__phocacart_orders AS o ON a.order_id = o.id' . ' WHERE o.user_id = ' . (int) $userId . ' AND a.type = ' . $db->quote('brutto');
$db->setQuery($query);
$total = $db->loadResult();
if (!$total) {
$total = 0;
}
}
return $total;
}