session = session(); $this->UserModel = new User_model(); $this->dModel = new Dashboard_model(); $this->cModel = new Common_model(); $this->creditsModel = new Member_credits_model(); $this->PackagesModel = new Packages_and_pricing_model(); $this->CreditsUsageTrackingModel = new Credits_usage_tracking_model(); $this->MailModel = new Email_template_model(); $this->VariableModel = new Variable_model(); $this->RuleModel = new Rule_model(); $this->Cart_token_model = new Cart_token_model(); helper(['form', 'url']); } public function index() { $pack_data['pack_data'] = $this->credits_pack(); $pack_data['token'] = ''; echo view('membership.php' , $pack_data); } public function credits_pack() { $data = $this->PackagesModel->where('package_type', 'Presales' )->findAll(); return $data; } public function add_package_cartdata() { $token = rand(10 , 99 ).rand(10 , 99 ).rand(10 , 99 ); if ($this->request->getVar('c_token')) { $tokendata = $this->Cart_token_model->where('md5(token)', $this->request->getVar('c_token') )->find(); $data['token'] = $tokendata[0]['token']; } else { $data['token'] = $token; } $data['primary_id'] = $this->request->getVar('id'); $data['table_name'] = 'packages_and_pricing'; $this->Cart_token_model->save($data); if ($this->request->getVar('c_token')) { $tokendata = $this->Cart_token_model->where('md5(token)', $this->request->getVar('c_token') )->find(); $data['token'] = md5($tokendata[0]['token']); } else { $data['token'] = md5($token); } echo json_encode($data); } public function view_cart($token) { $data = $this->Cart_token_model->where('md5(token)', $token )->findAll(); if ($data) { $array = []; foreach ($data as $key => $value) { $arr = $this->PackagesModel->where('id', $value['primary_id'] )->find(); array_push($array , $arr[0]); } $val['pack_id'] = $data; $val['gst'] = $this->RuleModel->where('rule_key', 3 )->find(); $val['pst'] = $this->RuleModel->where('rule_key', 4 )->find(); $val['tokendata'] = $array; $val['token'] = $data[0]['token']; echo view('cart.php',$val); } else { $this->index(); } } public function continue_shopping($token) { $tokendata = $this->Cart_token_model->where('md5(token)', $token )->find(); $data['token'] = $tokendata[0]['token']; $data['pack_data'] = $this->credits_pack(); echo view('membership.php',$data); } public function remove_product($id) { $tokendata = $this->Cart_token_model->where('md5(id)', $id )->findAll(); $deletedata = $this->Cart_token_model->where('md5(id)', $id )->delete(); return redirect()->to(base_url()."view_cart/".md5($tokendata[0]['token'])); } // ----------------------------------------------- }