Back to PhocacartReward class

Method getTotalPointsByOrderId

public static
getTotalPointsByOrderId
(mixed $orderId)

Method getTotalPointsByOrderId - Source code

public static function getTotalPointsByOrderId($orderId)
{
    if ((int) $orderId > 0) {
        $db = Factory::getDBO();
        $query = 'SELECT SUM(a.points) FROM #__phocacart_reward_points AS a' . ' WHERE a.order_id = ' . (int) $orderId . ' GROUP BY a.order_id' . ' ORDER BY a.id';
        $db->setQuery($query);
        $total = $db->loadResult();
        if (!$total) {
            $total = 0;
        }
        return (int) $total;
    }
    return 0;
}