public function getProductPrices($product_id, $userid, $quantity = 1) { $leftjoin = ""; $userArr = $this->_session->get('rs_user'); $helper = new redhelper(); if (empty($userArr)) { $userArr = $this->_userhelper->createUserSession($userid); } $shopperGroupId = $userArr['rs_user_shopperGroup']; if ($helper->isredCRM()) { if ($this->_session->get('isredcrmuser')) { $crmDebitorHelper = new crmDebitorHelper(); $debitor_id_tot = $crmDebitorHelper->getContactPersons(0, 0, 0, $userid); $debitor_id = $debitor_id_tot[0]->section_id; $details = $crmDebitorHelper->getDebitor($debitor_id); $userid = $details[0]->user_id; } } $query = $this->_db->getQuery(true); $query->select(' p.price_id,p.product_price,p.product_currency,p.discount_price, p.discount_start_date, p.discount_end_date '); if ($userid) { $query->join('LEFT', $this->_table_prefix . 'users_info AS u ON u.shopper_group_id = p.shopper_group_id'); $and = " u.user_id = " . (int) $userid . " AND u.address_type='BT' "; } else { $and = " p.shopper_group_id = '" . $shopperGroupId . "' "; } $query->from($this->_table_prefix . 'product_price AS p'); $query->where('p.product_id = ' . (int) $product_id); $query->where($and); $query->where(' (( p.price_quantity_start <= ' . (int) $quantity . ' AND p.price_quantity_end >= "' . $quantity . '" ) OR (p.price_quantity_start = "0" AND p.price_quantity_end = "0"))'); $query->order('price_quantity_start ASC LIMIT 0,1 '); $this->_db->setQuery($query); $result = $this->_db->loadObject(); if (count($result) > 0) { if ($result->discount_price != 0 && $result->discount_start_date != 0 && $result->discount_end_date != 0 && $result->discount_start_date <= time() && $result->discount_end_date >= time() && $result->discount_price < $result->product_price) { $result->product_price = $result->discount_price; } } return $result; }
/** * Method for checkout second step. * * @return void */ public function checkoutnext() { $app = JFactory::getApplication(); $session = JFactory::getSession(); $post = JRequest::get('post'); $user = JFactory::getUser(); $cart = $session->get('cart'); if (isset($post['extrafields0']) && isset($post['extrafields']) && count($cart) > 0) { if (count($post['extrafields0']) > 0 && count($post['extrafields']) > 0) { for ($r = 0; $r < count($post['extrafields']); $r++) { $post['extrafields_values'][$post['extrafields'][$r]] = $post['extrafields0'][$r]; } $cart['extrafields_values'] = $post['extrafields_values']; $session->set('cart', $cart); } } $Itemid = JRequest::getInt('Itemid'); $users_info_id = JRequest::getInt('users_info_id'); $helper = new redhelper(); $chk = $this->chkvalidation($users_info_id); if (!empty($chk)) { if ($chk == 1) { $link = 'index.php?option=com_redshop&view=account_billto&return=checkout&setexit=0&Itemid=' . $Itemid; } else { $link = 'index.php?option=com_redshop&view=account_shipto&task=addshipping&setexit=0&return=checkout&infoid=' . $users_info_id . '&Itemid=' . $Itemid; } $app->Redirect($link); } if ($helper->isredCRM()) { if (($session->get('isredcrmuser_debitor') || $session->get('isredcrmuser')) && ($post['payment_method_id'] == "rs_payment_banktransfer" || $post['payment_method_id'] == "rs_payment_banktransfer2" || $post['payment_method_id'] == "rs_payment_banktransfer3" || $post['payment_method_id'] == "rs_payment_banktransfer4" || $post['payment_method_id'] == "rs_payment_banktransfer5" || $post['payment_method_id'] == "rs_payment_cashtransfer" || $post['payment_method_id'] == "rs_payment_cashsale" || $post['payment_method_id'] == "rs_payment_banktransfer_discount")) { $crmDebitorHelper = new crmDebitorHelper(); if ($session->get('isredcrmuser_debitor')) { $debitor_id = $session->get('isredcrmuser_debitor'); } else { $debitor_id_tot = $crmDebitorHelper->getContactPersons(0, 0, 0, $user->id); $debitor_id = $debitor_id_tot[0]->section_id; } $details = $crmDebitorHelper->getDebitor($debitor_id); if (count($details) > 0 && $details[0]->is_company == 1) { $unpaid = $details[0]->debitor_unpaid_balance; $max_credit = $details[0]->debitor_max_credit; $total = $cart['total']; if ($max_credit <= $unpaid + $total) { $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $msg = JText::_('DEBITOR_CREDIT_LIMIT_EXCEED'); $link = JRoute::_('index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid, false); $this->setRedirect($link, $msg); } } } } $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $ccinfo = JRequest::getVar('ccinfo'); $errormsg = ""; if ($ccinfo == 1) { $errormsg = $this->setcreditcardInfo(); } if ($errormsg != "") { $app->Redirect('index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid, $errormsg); } else { $view = $this->getView('checkout', 'next'); parent::display(); } }