suseendhiran
This commit is contained in:
parent
8550a1c96e
commit
1b26b74c86
@ -11,6 +11,7 @@ use App\Models\Email_template_model;
|
||||
use App\Models\Variable_model;
|
||||
use App\Models\Rule_model;
|
||||
use App\Models\Cart_token_model;
|
||||
use App\Models\Cart_model;
|
||||
class Cart_controller extends BaseController
|
||||
{
|
||||
public $session;
|
||||
@ -27,6 +28,7 @@ class Cart_controller extends BaseController
|
||||
$this->VariableModel = new Variable_model();
|
||||
$this->RuleModel = new Rule_model();
|
||||
$this->Cart_token_model = new Cart_token_model();
|
||||
$this->cartModel = new Cart_model();
|
||||
helper(['form', 'url']);
|
||||
}
|
||||
public function index()
|
||||
@ -44,98 +46,170 @@ class Cart_controller extends BaseController
|
||||
|
||||
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'];
|
||||
|
||||
foreach ($tokendata as $key => $value)
|
||||
if (!session()->has('logged_user'))
|
||||
{
|
||||
$token = rand(10 , 99 ).rand(10 , 99 ).rand(10 , 99 );
|
||||
if ($this->request->getVar('c_token'))
|
||||
{
|
||||
if ($value['primary_id'] == $this->request->getVar('id'))
|
||||
$tokendata = $this->Cart_token_model->where('md5(token)', $this->request->getVar('c_token') )->find();
|
||||
$data['token'] = $tokendata[0]['token'];
|
||||
|
||||
foreach ($tokendata as $key => $value)
|
||||
{
|
||||
$count = $tokendata[$key]['count'] + 1;
|
||||
$this->Cart_token_model->where('id', $tokendata[$key]['id'] )->set(array( 'count' => $count ))->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($tokendata) == 1)
|
||||
if ($value['primary_id'] == $this->request->getVar('id'))
|
||||
{
|
||||
$data['primary_id'] = $this->request->getVar('id');
|
||||
$data['table_name'] = 'packages_and_pricing';
|
||||
$data['count'] = 1;
|
||||
$this->Cart_token_model->save($data);
|
||||
$count = $tokendata[$key]['count'] + 1;
|
||||
$this->Cart_token_model->where('id', $tokendata[$key]['id'] )->set(array( 'count' => $count ))->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($tokendata) == 1)
|
||||
{
|
||||
$data['primary_id'] = $this->request->getVar('id');
|
||||
$data['table_name'] = 'packages_and_pricing';
|
||||
$data['count'] = 1;
|
||||
$this->Cart_token_model->save($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['token'] = $token;
|
||||
else
|
||||
{
|
||||
$data['token'] = $token;
|
||||
|
||||
$data['primary_id'] = $this->request->getVar('id');
|
||||
$data['table_name'] = 'packages_and_pricing';
|
||||
$data['count'] = 1;
|
||||
$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();
|
||||
$data['primary_id'] = $this->request->getVar('id');
|
||||
$data['table_name'] = 'package_and_pricing';
|
||||
$data['count'] = 1;
|
||||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = $this->cartModel->where('md5(member_id)', $this->request->getVar('c_token') )->where('pack_id', $this->request->getVar('id') )->find();
|
||||
if ($data)
|
||||
{
|
||||
$array = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$arr = $this->PackagesModel->where('id', $value['primary_id'] )->find();
|
||||
array_push($array , $arr[0]);
|
||||
$this->cartModel->where('md5(member_id)', $this->request->getVar('c_token') )->where('pack_id', $this->request->getVar('id') )->set(array( 'count' => $data[0]['count'] + 1 ))->update();
|
||||
|
||||
$val['token'] = md5($this->session->get('logged_user'));
|
||||
echo json_encode($val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['member_id'] = $this->session->get('logged_user');
|
||||
$data['pack_id'] = $this->request->getVar('id');
|
||||
$data['count'] = 1;
|
||||
$this->cartModel->save($data);
|
||||
$val['token'] = md5($this->session->get('logged_user'));
|
||||
echo json_encode($val);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function view_cart($token = null)
|
||||
{
|
||||
if (!session()->has('logged_user'))
|
||||
{
|
||||
$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();
|
||||
}
|
||||
$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();
|
||||
$data = $this->cartModel->where('md5(member_id)', $token )->findAll();
|
||||
if ($data)
|
||||
{
|
||||
$array = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$arr = $this->PackagesModel->where('id', $value['pack_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'] = $this->session->get('logged_user');
|
||||
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);
|
||||
if (!session()->has('logged_user'))
|
||||
{
|
||||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tokendata = $this->cartModel->where('md5(member_id)', $token )->findAll();
|
||||
$data['token'] = $tokendata[0]['member_id'];
|
||||
$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']));
|
||||
if (!session()->has('logged_user'))
|
||||
{
|
||||
$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']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$deletedata = $this->cartModel->where('md5(id)', $id )->delete();
|
||||
return redirect()->to(base_url()."view_cart/".md5($this->session->get('logged_user')));
|
||||
}
|
||||
}
|
||||
|
||||
public function change_count_onclick()
|
||||
{
|
||||
try {
|
||||
$this->Cart_token_model->where('id', $this->request->getVar('id') )->set(array( 'count' => $this->request->getVar('count') ))->update();
|
||||
echo true;
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
if (!session()->has('logged_user'))
|
||||
{
|
||||
$this->Cart_token_model->where('id', $this->request->getVar('id') )->set(array( 'count' => $this->request->getVar('count') ))->update();
|
||||
echo true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cartModel->where('id', $this->request->getVar('id') )->set(array( 'count' => $this->request->getVar('count') ))->update();
|
||||
echo true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,19 +5,19 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" href="assets/images/favicon.png" sizes="192x192" />
|
||||
<link rel="apple-touch-icon" href="assets/images/favicon.png" />
|
||||
<link rel="icon" href="<?= base_url()."/public"; ?>/assets/member_images/favicon.png" sizes="192x192" />
|
||||
<link rel="apple-touch-icon" href="<?= base_url()."/public"; ?>/assets/member_images/favicon.png" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/front-style.css">
|
||||
<link rel="stylesheet" href="<?= base_url()."/public"; ?>/assets/css/front-style.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
|
||||
</head>
|
||||
<body class="payment">
|
||||
|
||||
<?php include 'module/header.php' ?>
|
||||
<?php include 'member_layout/header.php' ?>
|
||||
|
||||
<section>
|
||||
<div class="container">
|
||||
@ -28,7 +28,7 @@
|
||||
<div class="row payment-head">
|
||||
<div class="col-lg-12">
|
||||
<div>
|
||||
<img src="assets/images/Vector.png" alt="" width="60" height="60"/>
|
||||
<img src="<?= base_url()."/public"; ?>/assets/member_images/Vector.png" alt="" width="60" height="60"/>
|
||||
<h1 class="sucessful-heading">Payment Successful!</h1>
|
||||
<p>The order confirmation has been sent to your registered mail id</p>
|
||||
</div>
|
||||
@ -59,7 +59,7 @@
|
||||
<div class="col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<img src="assets/images/cart-icon.png" alt="" width="70" height="70">
|
||||
<img src="<?= base_url()."/public"; ?>/assets/member_images/cart-icon.png" alt="" width="70" height="70">
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
<div class="product-name">Evo Pack 1</div>
|
||||
@ -132,7 +132,7 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include 'module/footer.php' ?>
|
||||
<?php include 'member_layout/footer.php' ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user