Back to PhocacartOrder class

Method saveRewardPoints

public
saveRewardPoints
(mixed $userId, mixed $points, mixed $orderBillingData, mixed $published = 0, mixed $type = 0)

Method saveRewardPoints - Source code

public function saveRewardPoints($userId, $points, $orderBillingData, $published = 0, $type = 0)
{
    $app = Factory::getApplication();
    $db = Factory::getDbo();
    $row = Table::getInstance('PhocacartRewardPoint', 'Table', array());
    $d = array();
    $d['date'] = $orderBillingData['date'];
    //gmdate('Y-m-d H:i:s');
    $d['published'] = (int) $published;
    $d['points'] = (int) $points;
    $d['user_id'] = (int) $userId;
    $d['order_id'] = (int) $orderBillingData['id'];
    $d['title'] = Text::_('COM_PHOCACART_ORDER_NUMBER') . ' ' . self::getOrderNumber($d['order_id'], $d['date'], $orderBillingData['order_number']) . ' (' . $d['date'] . ')';
    $d['type'] = (int) $type;
    if (!$row->bind($d)) {
        //throw new Exception($row->getError());
        $msg = Text::_($row->getError());
        $app->enqueueMessage($msg, 'error');
        return false;
    }
    if (!$row->check()) {
        //throw new Exception($row->getError());
        $msg = Text::_($row->getErrorMsg());
        $app->enqueueMessage($msg, 'error');
        return false;
    }
    if (!$row->store()) {
        //throw new Exception($row->getError());
        $msg = Text::_($row->getErrorMsg());
        $app->enqueueMessage($msg, 'error');
        return false;
    }
    return true;
}