Back to PhocacartOrder class

Method saveOrderUsers

public
saveOrderUsers
(mixed $d, mixed $orderId)

Method saveOrderUsers - Source code

public function saveOrderUsers($d, $orderId)
{
    $app = Factory::getApplication();
    $db = Factory::getDbo();
    $d = (array) $d;
    if (!isset($d['id'])) {
        $d['id'] = 0;
        // Guest Checkout
        $d['user_id'] = 0;
    }
    $d['order_id'] = (int) $orderId;
    $d['user_address_id'] = (int) $d['id'];
    $d['user_token'] = PhocacartUtils::getToken();
    $userGroups = PhocacartGroup::getGroupsById((int) $d['user_id'], 1, 1);
    $d['user_groups'] = serialize($userGroups);
    unset($d['id']);
    // we do new autoincrement
    $row = Table::getInstance('PhocacartOrderUsers', '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->getError());
        $app->enqueueMessage($msg, 'error');
        return false;
    }
    if (!$row->store()) {
        //throw new Exception($row->getError());
        $msg = Text::_($row->getError());
        $app->enqueueMessage($msg, 'error');
        return false;
    }
    return true;
}