Back to PhocacartOrder class

Method saveOrderDiscounts

public
saveOrderDiscounts
(mixed $discountTitle, mixed $totalD, mixed $orderId, mixed $type = 0)

Method saveOrderDiscounts - Source code

public function saveOrderDiscounts($discountTitle, $totalD, $orderId, $type = 0)
{
    $app = Factory::getApplication();
    $db = Factory::getDbo();
    $d = array();
    $d['order_id'] = (int) $orderId;
    //$d['discount_id']		= (int)$discount['id'];
    $d['title'] = $discountTitle;
    $d['amount'] = $totalD['dnetto'];
    // get the value from total
    $d['netto'] = $totalD['dnetto'];
    $d['brutto'] = $totalD['dbrutto'];
    $row = Table::getInstance('PhocacartOrderDiscounts', 'Table', array());
    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;
}