| Line 1... |
Line 1... |
| 1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
| 2 |
|
2 |
|
| 3 |
class Cart extends MY_Controller {
|
3 |
class Cart extends MY_Controller {
|
| 4 |
|
4 |
|
| 5 |
public $layoutName ='';
|
5 |
public $layoutName ='';
|
| 6 |
|
6 |
|
| 7 |
function __construct() {
|
7 |
function __construct() {
|
| 8 |
|
8 |
|
| 9 |
// Call the CI_controller constructor
|
9 |
// Call the CI_controller constructor
|
| 10 |
parent::__construct();
|
10 |
parent::__construct();
|
| 11 |
// $admin = $this->session->userdata('admin');
|
11 |
// $admin = $this->session->userdata('admin');
|
| 12 |
// if(!isset($admin) || empty($admin)) {
|
12 |
// if(!isset($admin) || empty($admin)) {
|
| 13 |
// redirect(base_url().'authorize');
|
13 |
// redirect(base_url().'authorize');
|
| 14 |
// }
|
14 |
// }
|
| 15 |
$this->output->set_header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
|
15 |
$this->output->set_header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
|
| 16 |
$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
16 |
$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
| 17 |
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
17 |
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
| 18 |
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
|
18 |
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
|
| 19 |
$this->output->set_header("Pragma: no-cache");
|
19 |
$this->output->set_header("Pragma: no-cache");
|
| 20 |
$this->layout->setlayout('layout/layout_main');
|
20 |
$this->layout->setlayout('layout/layout_main');
|
| 21 |
$this->load->model('cart_model');
|
21 |
$this->load->model('cart_model');
|
| 22 |
$this->layoutName= $this->layout->getLayout();
|
22 |
$this->layoutName= $this->layout->getLayout();
|
| 23 |
$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
|
23 |
$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
|
| 24 |
//print_r($this->session->userdata);
|
24 |
//print_r($this->session->userdata);
|
| 25 |
|
25 |
|
| 26 |
}
|
26 |
}
|
| 27 |
public function index()
|
27 |
public function index()
|
| 28 |
{
|
28 |
{
|
| 29 |
$authorized = $this->session->userdata('authorized');
|
29 |
$authorized = $this->session->userdata('authorized');
|
| 30 |
//standard array
|
30 |
//standard array
|
| 31 |
$configdata = $this->config->item('cart');
|
31 |
$configdata = $this->config->item('cart');
|
| 32 |
$cachemodule = array('header','footer');
|
32 |
$cachemodule = array('header','footer');
|
| 33 |
$configdata = getCache($configdata,$cachemodule);
|
33 |
$configdata = getCache($configdata,$cachemodule);
|
| 34 |
$data = array();
|
34 |
$data = array();
|
| 35 |
if(isset($authorized) && !empty($authorized)){
|
35 |
if(isset($authorized) && !empty($authorized)){
|
| 36 |
$_GET['userId'] = $authorized['Id'];
|
36 |
$_GET['userId'] = $authorized['Id'];
|
| 37 |
$_GET['Id'] = $authorized['cartId'];
|
37 |
$_GET['Id'] = $authorized['cartId'];
|
| 38 |
if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {
|
38 |
if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {
|
| 39 |
$_GET['privateDealUser'] = 'true';
|
39 |
$_GET['privateDealUser'] = 'true';
|
| 40 |
}
|
40 |
}
|
| 41 |
$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
|
41 |
$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
|
| 42 |
$_GET['autoApplicationOff'] = 'false';
|
42 |
$_GET['autoApplicationOff'] = 'false';
|
| 43 |
if(isset($isAutoApplicationOff) && !empty($isAutoApplicationOff)) {
|
43 |
if(isset($isAutoApplicationOff) && !empty($isAutoApplicationOff)) {
|
| 44 |
$_GET['autoApplicationOff'] = 'true';
|
44 |
$_GET['autoApplicationOff'] = 'true';
|
| 45 |
}
|
45 |
}
|
| 46 |
if($authorized['isLoggedIn'] == 1){
|
46 |
if($authorized['isLoggedIn'] == 1){
|
| 47 |
$_GET['isLoggedIn'] = 'true';
|
47 |
$_GET['isLoggedIn'] = 'true';
|
| 48 |
}
|
48 |
}
|
| 49 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
49 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 50 |
$_GET['isLoggedIn'] = 'false';
|
50 |
$_GET['isLoggedIn'] = 'false';
|
| 51 |
}
|
51 |
}
|
| 52 |
unset($configdata['module']['response'][0]);
|
52 |
unset($configdata['module']['response'][0]);
|
| 53 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$configdata['module']);
|
53 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$configdata['module']);
|
| 54 |
if(isset($data['response']['response']['carts'][0]->lines))
|
54 |
if(isset($data['response']['response']['carts'][0]->lines))
|
| 55 |
$cartCount = sizeof($data['response']['response']['carts'][0]->lines);
|
55 |
$cartCount = sizeof($data['response']['response']['carts'][0]->lines);
|
| 56 |
$authorized = $this->session->userdata('authorized');
|
56 |
$authorized = $this->session->userdata('authorized');
|
| 57 |
if(isset($cartMessage) and !empty($cartMessage))
|
57 |
if(isset($cartMessage) and !empty($cartMessage))
|
| 58 |
{
|
58 |
{
|
| 59 |
if(!isset($data['response']['response']['carts'][0]->message) and empty($data['response']['response']['carts'][0]->message)){
|
59 |
if(!isset($data['response']['response']['carts'][0]->message) and empty($data['response']['response']['carts'][0]->message)){
|
| 60 |
$data['response']['response']['carts'][0]->message = $cartMessage;
|
60 |
$data['response']['response']['carts'][0]->message = $cartMessage;
|
| 61 |
}
|
61 |
}
|
| 62 |
}
|
62 |
}
|
| 63 |
if(isset($authorized) && !empty($authorized)){
|
63 |
if(isset($authorized) && !empty($authorized)){
|
| 64 |
$newValues = $authorized;
|
64 |
$newValues = $authorized;
|
| 65 |
$newValues['totalItems'] = $cartCount;
|
65 |
$newValues['totalItems'] = $cartCount;
|
| 66 |
$this->session->set_userdata('authorized',$newValues);
|
66 |
$this->session->set_userdata('authorized',$newValues);
|
| 67 |
}
|
67 |
}
|
| 68 |
$this->lessphp->object()->ccompile('assets/css/cart.less','assets/css/cart.css');
|
68 |
$this->lessphp->object()->ccompile('assets/css/cart.less','assets/css/cart.css');
|
| 69 |
$data['stylesheet'] = 'cart.css';
|
69 |
$data['stylesheet'] = 'cart.css';
|
| 70 |
if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
|
70 |
if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
|
| 71 |
{
|
71 |
{
|
| 72 |
foreach($cachemodule as $cm)
|
72 |
foreach($cachemodule as $cm)
|
| 73 |
{
|
73 |
{
|
| 74 |
if(isset($configdata[$cm]) and !empty($configdata[$cm]))
|
74 |
if(isset($configdata[$cm]) and !empty($configdata[$cm]))
|
| 75 |
{
|
75 |
{
|
| 76 |
$data['response'][$cm]=$configdata[$cm];
|
76 |
$data['response'][$cm]=$configdata[$cm];
|
| 77 |
}
|
77 |
}
|
| 78 |
}
|
78 |
}
|
| 79 |
}
|
79 |
}
|
| 80 |
$cartMessage = $this->session->userdata('cartmessage');
|
80 |
$cartMessage = $this->session->userdata('cartmessage');
|
| 81 |
if(isset($cartMessage) and !empty($cartMessage))
|
81 |
if(isset($cartMessage) and !empty($cartMessage))
|
| 82 |
{
|
82 |
{
|
| 83 |
if(!isset($data['response']['response']['carts'][0]->message) or empty($data['response']['response']['carts'][0]->message)){
|
83 |
if(!isset($data['response']['response']['carts'][0]->message) or empty($data['response']['response']['carts'][0]->message)){
|
| 84 |
$data['response']['response']['carts'][0]->message=$cartMessage;
|
84 |
$data['response']['response']['carts'][0]->message=$cartMessage;
|
| 85 |
}
|
85 |
}
|
| 86 |
}
|
86 |
}
|
| 87 |
$this->session->set_userdata('cartmessage','');
|
87 |
error_log("Private Deal User".$authorized['isPrivateDealUser']);
|
| 88 |
setCache($configdata['module'],$cachemodule,$data['response']);
|
88 |
if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {
|
| 89 |
$this->layout->view('cart/cart_view',$data);
|
89 |
$userId = $this->session->userdata['authorized']['Id'];
|
| 90 |
}else{
|
90 |
$ch = curl_init();
|
| 91 |
unset($configdata['module']['response'][1]);
|
91 |
$url = 'http://shop2020.in:8080/mobileapi/private-deals/1/?userId=7445884&isLoggedIn=true&privateDealUser=true';
|
| 92 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$configdata['module']);
|
92 |
// Set the url, number of POST vars, POST data
|
| 93 |
$this->lessphp->object()->ccompile('assets/css/cart.less','assets/css/cart.css');
|
93 |
curl_setopt($ch, CURLOPT_URL, $url);
|
| 94 |
$data['stylesheet'] = 'cart.css';
|
94 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 95 |
if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
|
95 |
|
| 96 |
{
|
96 |
// Disabling SSL Certificate support temporarly
|
| 97 |
foreach($cachemodule as $cm)
|
97 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 98 |
{
|
98 |
|
| 99 |
if(isset($configdata[$cm]) and !empty($configdata[$cm]))
|
99 |
// Execute post
|
| 100 |
{
|
100 |
$result = curl_exec($ch);
|
| 101 |
$data['response'][$cm]=$configdata[$cm];
|
101 |
if ($result === FALSE) {
|
| 102 |
}
|
102 |
die('Curl failed: ' . curl_error($ch));
|
| 103 |
}
|
103 |
}
|
| 104 |
}
|
104 |
$res = json_decode($result,1);
|
| 105 |
$cartMessage = $this->session->userdata('cartmessage');
|
105 |
$data['privatedeals']=$res;
|
| 106 |
if(isset($cartMessage) and !empty($cartMessage))
|
106 |
}
|
| 107 |
{
|
107 |
$this->session->set_userdata('cartmessage','');
|
| 108 |
if(!isset($data['response']['response']['carts'][0]->message) or empty($data['response']['response']['carts'][0]->message)){
|
108 |
setCache($configdata['module'],$cachemodule,$data['response'],$data['privatedeals']);
|
| 109 |
$data['response']['response']['carts'][0]->message=$cartMessage;
|
109 |
$this->layout->view('cart/cart_view',$data);
|
| 110 |
}
|
110 |
}else{
|
| 111 |
}
|
111 |
unset($configdata['module']['response'][1]);
|
| 112 |
$this->session->set_userdata('cartmessage','');
|
112 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$configdata['module']);
|
| 113 |
setCache($configdata['module'],$cachemodule,$data['response']);
|
113 |
$this->lessphp->object()->ccompile('assets/css/cart.less','assets/css/cart.css');
|
| 114 |
$this->layout->view('cart/carts',$data);
|
114 |
$data['stylesheet'] = 'cart.css';
|
| 115 |
}
|
115 |
if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
|
| 116 |
}
|
116 |
{
|
| 117 |
|
117 |
foreach($cachemodule as $cm)
|
| 118 |
|
118 |
{
|
| 119 |
public function add($id=null,$email=null,$itemname)
|
119 |
if(isset($configdata[$cm]) and !empty($configdata[$cm]))
|
| 120 |
{
|
120 |
{
|
| 121 |
$response=array();
|
121 |
$data['response'][$cm]=$configdata[$cm];
|
| 122 |
|
122 |
}
|
| 123 |
$authorized = $this->session->userdata('authorized');
|
123 |
}
|
| 124 |
$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
|
124 |
}
|
| 125 |
|
125 |
$cartMessage = $this->session->userdata('cartmessage');
|
| 126 |
if(isset($id) and !empty($id) and is_numeric($id))
|
126 |
if(isset($cartMessage) and !empty($cartMessage))
|
| 127 |
{
|
127 |
{
|
| 128 |
//if user logged-in
|
128 |
if(!isset($data['response']['response']['carts'][0]->message) or empty($data['response']['response']['carts'][0]->message)){
|
| 129 |
$_POST['itemId'] = $id;
|
129 |
$data['response']['response']['carts'][0]->message=$cartMessage;
|
| 130 |
}
|
130 |
}
|
| 131 |
else{
|
131 |
}
|
| 132 |
redirect(base_url());
|
132 |
$this->session->set_userdata('cartmessage','');
|
| 133 |
}
|
133 |
setCache($configdata['module'],$cachemodule,$data['response']);
|
| 134 |
if(isset($authorized) && !empty($authorized)){
|
134 |
$this->layout->view('cart/carts',$data);
|
| 135 |
$_POST['userId'] = $authorized['Id'];
|
135 |
}
|
| 136 |
$_POST['Id'] = $authorized['cartId'];
|
136 |
}
|
| 137 |
|
137 |
|
| 138 |
if($authorized['isLoggedIn'] == 1){
|
138 |
|
| 139 |
$_POST['isLoggedIn'] = 'true';
|
139 |
public function add($id=null,$email=null,$itemname)
|
| 140 |
}
|
140 |
{
|
| 141 |
elseif((isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn']))) {
|
141 |
$response=array();
|
| 142 |
$_POST['isLoggedIn'] = 'false';
|
142 |
|
| 143 |
}
|
143 |
$authorized = $this->session->userdata('authorized');
|
| 144 |
}
|
144 |
$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
|
| 145 |
else{
|
145 |
|
| 146 |
$response = $this->anonymous();
|
146 |
if(isset($id) and !empty($id) and is_numeric($id))
|
| 147 |
if(isset($response['authorized']) && !empty($response['authorized'])){
|
147 |
{
|
| 148 |
$authorized = $response['authorized'];
|
148 |
//if user logged-in
|
| 149 |
$_POST['userId'] = $authorized['Id'];
|
149 |
$_POST['itemId'] = $id;
|
| 150 |
$_POST['Id'] = $authorized['cartId'];
|
150 |
}
|
| 151 |
if(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])){
|
151 |
else{
|
| 152 |
$_POST['isLoggedIn'] = 'false';
|
152 |
redirect(base_url());
|
| 153 |
}
|
153 |
}
|
| 154 |
}
|
154 |
if(isset($authorized) && !empty($authorized)){
|
| 155 |
}
|
155 |
$_POST['userId'] = $authorized['Id'];
|
| 156 |
if(isset($email) && $email != 'null'){
|
156 |
$_POST['Id'] = $authorized['cartId'];
|
| 157 |
$_POST['email'] = $email;
|
157 |
|
| 158 |
}
|
158 |
if($authorized['isLoggedIn'] == 1){
|
| 159 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_add'));
|
159 |
$_POST['isLoggedIn'] = 'true';
|
| 160 |
if(isset($response['response']['addcart'][0]->message) && !empty($response['response']['addcart'][0]->message)){
|
160 |
}
|
| 161 |
if(isset($itemname) && $itemname != 'null'){
|
161 |
elseif((isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn']))) {
|
| 162 |
if(!isset($email) || $email == 'null'){
|
162 |
$_POST['isLoggedIn'] = 'false';
|
| 163 |
$productinfo = 'productinfo'.$itemname;
|
163 |
}
|
| 164 |
deleteFileCache($productinfo);
|
164 |
}
|
| 165 |
}
|
165 |
else{
|
| 166 |
}
|
166 |
$response = $this->anonymous();
|
| 167 |
echo json_encode($response['response']);
|
167 |
if(isset($response['authorized']) && !empty($response['authorized'])){
|
| 168 |
}
|
168 |
$authorized = $response['authorized'];
|
| 169 |
elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl == 'cart'){
|
169 |
$_POST['userId'] = $authorized['Id'];
|
| 170 |
$authorized = $this->session->userdata('authorized');
|
170 |
$_POST['Id'] = $authorized['cartId'];
|
| 171 |
if(isset($authorized) && !empty($authorized)){
|
171 |
if(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])){
|
| 172 |
$cartCount = $authorized['totalItems'];
|
172 |
$_POST['isLoggedIn'] = 'false';
|
| 173 |
$newValues = $authorized;
|
173 |
}
|
| 174 |
$newValues['totalItems'] = $cartCount+1;
|
174 |
}
|
| 175 |
$this->session->set_userdata('authorized',$newValues);
|
175 |
}
|
| 176 |
}
|
176 |
if(isset($email) && $email != 'null'){
|
| 177 |
echo json_encode($response['response']);
|
177 |
$_POST['email'] = $email;
|
| 178 |
//redirect(base_url().strtolower(__CLASS__),'refresh');
|
178 |
}
|
| 179 |
}elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl != 'cart'){
|
179 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_add'));
|
| 180 |
echo json_encode($response['response']);
|
180 |
if(isset($response['response']['addcart'][0]->message) && !empty($response['response']['addcart'][0]->message)){
|
| 181 |
}
|
181 |
if(isset($itemname) && $itemname != 'null'){
|
| 182 |
}
|
182 |
if(!isset($email) || $email == 'null'){
|
| 183 |
public function update($id=null,$qty=null)
|
183 |
$productinfo = 'productinfo'.$itemname;
|
| 184 |
{
|
184 |
deleteFileCache($productinfo);
|
| 185 |
$response=array();
|
185 |
}
|
| 186 |
$authorized = $this->session->userdata('authorized');
|
186 |
}
|
| 187 |
if(isset($id) and !empty($id))
|
187 |
echo json_encode($response['response']);
|
| 188 |
{
|
188 |
}
|
| 189 |
//if user logged-in
|
189 |
elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl == 'cart'){
|
| 190 |
$_POST['itemId'] = $id;
|
190 |
$authorized = $this->session->userdata('authorized');
|
| 191 |
}
|
191 |
if(isset($authorized) && !empty($authorized)){
|
| 192 |
if(isset($qty) and !empty($qty))
|
192 |
$cartCount = $authorized['totalItems'];
|
| 193 |
{
|
193 |
$newValues = $authorized;
|
| 194 |
//if user logged-in
|
194 |
$newValues['totalItems'] = $cartCount+1;
|
| 195 |
$_POST['quantity'] = $qty;
|
195 |
$this->session->set_userdata('authorized',$newValues);
|
| 196 |
}
|
196 |
}
|
| 197 |
if(isset($authorized) && !empty($authorized)){
|
197 |
echo json_encode($response['response']);
|
| 198 |
$_POST['userId'] = $authorized['Id'];
|
198 |
//redirect(base_url().strtolower(__CLASS__),'refresh');
|
| 199 |
$_POST['_method'] = 'put';
|
199 |
}elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl != 'cart'){
|
| 200 |
$cartId = $authorized['cartId'];
|
200 |
echo json_encode($response['response']);
|
| 201 |
if($authorized['isLoggedIn'] == 1){
|
201 |
}
|
| 202 |
$_POST['isLoggedIn'] = 'true';
|
202 |
}
|
| 203 |
}
|
203 |
public function update($id=null,$qty=null)
|
| 204 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
204 |
{
|
| 205 |
$_POST['isLoggedIn'] = 'false';
|
205 |
$response=array();
|
| 206 |
}
|
206 |
$authorized = $this->session->userdata('authorized');
|
| 207 |
}
|
207 |
if(isset($id) and !empty($id))
|
| 208 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_update'),$cartId);
|
208 |
{
|
| 209 |
$message = $data['response']['response']['updatecart'][0]->message;
|
209 |
//if user logged-in
|
| 210 |
|
210 |
$_POST['itemId'] = $id;
|
| 211 |
if(isset($message) and !empty($message))
|
211 |
}
|
| 212 |
{
|
212 |
if(isset($qty) and !empty($qty))
|
| 213 |
$this->session->set_userdata('cartmessage',$message);
|
213 |
{
|
| 214 |
redirect(base_url().strtolower(__CLASS__));
|
214 |
//if user logged-in
|
| 215 |
}else{
|
215 |
$_POST['quantity'] = $qty;
|
| 216 |
redirect(base_url().strtolower(__CLASS__));
|
216 |
}
|
| 217 |
}
|
217 |
if(isset($authorized) && !empty($authorized)){
|
| 218 |
}
|
218 |
$_POST['userId'] = $authorized['Id'];
|
| 219 |
public function delete($id=null)
|
219 |
$_POST['_method'] = 'put';
|
| 220 |
{
|
220 |
$cartId = $authorized['cartId'];
|
| 221 |
|
221 |
if($authorized['isLoggedIn'] == 1){
|
| 222 |
$authorized = $this->session->userdata('authorized');
|
222 |
$_POST['isLoggedIn'] = 'true';
|
| 223 |
if(isset($id) and !empty($id) and is_numeric($id))
|
223 |
}
|
| 224 |
{
|
224 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 225 |
//if user logged-in
|
225 |
$_POST['isLoggedIn'] = 'false';
|
| 226 |
$_POST['itemId'] = $id;
|
226 |
}
|
| 227 |
}
|
227 |
}
|
| 228 |
else{
|
228 |
$data['response']=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_update'),$cartId);
|
| 229 |
redirect(base_url());
|
229 |
$message = $data['response']['response']['updatecart'][0]->message;
|
| 230 |
}
|
230 |
|
| 231 |
if(isset($authorized) && !empty($authorized)){
|
231 |
if(isset($message) and !empty($message))
|
| 232 |
$_POST['userId'] = $authorized['Id'];
|
232 |
{
|
| 233 |
$_POST['_method'] = 'delete';
|
233 |
$this->session->set_userdata('cartmessage',$message);
|
| 234 |
$cartId = $authorized['cartId'];
|
234 |
redirect(base_url().strtolower(__CLASS__));
|
| 235 |
if($authorized['isLoggedIn'] == 1){
|
235 |
}else{
|
| 236 |
$_POST['isLoggedIn'] = 'true';
|
236 |
redirect(base_url().strtolower(__CLASS__));
|
| 237 |
}
|
237 |
}
|
| 238 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
238 |
}
|
| 239 |
$_POST['isLoggedIn'] = 'false';
|
239 |
public function delete($id=null)
|
| 240 |
}
|
240 |
{
|
| 241 |
}
|
241 |
|
| 242 |
$response=array();
|
242 |
$authorized = $this->session->userdata('authorized');
|
| 243 |
if(isset($id) and !empty($id))
|
243 |
if(isset($id) and !empty($id) and is_numeric($id))
|
| 244 |
{
|
244 |
{
|
| 245 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_delete'),$cartId);
|
245 |
//if user logged-in
|
| 246 |
if(isset($response['response']['deletecart'][0]->lines)) {
|
246 |
$_POST['itemId'] = $id;
|
| 247 |
$cartCount = sizeof($response['response']['deletecart'][0]->lines);
|
247 |
}
|
| 248 |
$authorized = $this->session->userdata('authorized');
|
248 |
else{
|
| 249 |
if(isset($authorized) && !empty($authorized)){
|
249 |
redirect(base_url());
|
| 250 |
$newValues = $authorized;
|
250 |
}
|
| 251 |
$newValues['totalItems'] = $cartCount;
|
251 |
if(isset($authorized) && !empty($authorized)){
|
| 252 |
$this->session->set_userdata('authorized',$newValues);
|
252 |
$_POST['userId'] = $authorized['Id'];
|
| 253 |
redirect(base_url().strtolower(__CLASS__));
|
253 |
$_POST['_method'] = 'delete';
|
| 254 |
}
|
254 |
$cartId = $authorized['cartId'];
|
| 255 |
}else{
|
255 |
if($authorized['isLoggedIn'] == 1){
|
| 256 |
redirect(base_url().strtolower(__CLASS__));
|
256 |
$_POST['isLoggedIn'] = 'true';
|
| 257 |
}
|
257 |
}
|
| 258 |
}
|
258 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 259 |
else
|
259 |
$_POST['isLoggedIn'] = 'false';
|
| 260 |
{
|
260 |
}
|
| 261 |
$response['response']['msg'] = 'Invalid Parameter!';
|
261 |
}
|
| 262 |
redirect(base_url().strtolower(__CLASS__));
|
262 |
$response=array();
|
| 263 |
|
263 |
if(isset($id) and !empty($id))
|
| 264 |
}
|
264 |
{
|
| 265 |
redirect(base_url().strtolower(__CLASS__));
|
265 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_delete'),$cartId);
|
| 266 |
|
266 |
if(isset($response['response']['deletecart'][0]->lines)) {
|
| 267 |
}
|
267 |
$cartCount = sizeof($response['response']['deletecart'][0]->lines);
|
| 268 |
public function coupon($code=null)
|
268 |
$authorized = $this->session->userdata('authorized');
|
| 269 |
{
|
269 |
if(isset($authorized) && !empty($authorized)){
|
| 270 |
$response=array();
|
270 |
$newValues = $authorized;
|
| 271 |
$authorized = $this->session->userdata('authorized');
|
271 |
$newValues['totalItems'] = $cartCount;
|
| 272 |
if(isset($authorized) && !empty($authorized)){
|
272 |
$this->session->set_userdata('authorized',$newValues);
|
| 273 |
$_GET['userId'] = $authorized['Id'];
|
273 |
redirect(base_url().strtolower(__CLASS__));
|
| 274 |
$_GET['action'] = 'applycoupon';
|
274 |
}
|
| 275 |
$cartId = $authorized['cartId'];
|
275 |
}else{
|
| 276 |
if($authorized['isLoggedIn'] == 1){
|
276 |
redirect(base_url().strtolower(__CLASS__));
|
| 277 |
$_GET['isLoggedIn'] = 'true';
|
277 |
}
|
| 278 |
}
|
278 |
}
|
| 279 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
279 |
else
|
| 280 |
$_GET['isLoggedIn'] = 'false';
|
280 |
{
|
| 281 |
}
|
281 |
$response['response']['msg'] = 'Invalid Parameter!';
|
| 282 |
}
|
282 |
redirect(base_url().strtolower(__CLASS__));
|
| 283 |
if(isset($code) and !empty($code))
|
283 |
|
| 284 |
{
|
284 |
}
|
| 285 |
//if user logged-in
|
285 |
redirect(base_url().strtolower(__CLASS__));
|
| 286 |
$_GET['coupon_code'] = $code;
|
286 |
|
| 287 |
//TODO: Move to a config file maybe
|
287 |
}
|
| 288 |
if($code=='saholicdeals') {
|
288 |
public function coupon($code=null)
|
| 289 |
$this->session->set_userdata('isAutoApplicationOff','false');
|
289 |
{
|
| 290 |
}
|
290 |
$response=array();
|
| 291 |
//$d=$this->input->get();
|
291 |
$authorized = $this->session->userdata('authorized');
|
| 292 |
}
|
292 |
if(isset($authorized) && !empty($authorized)){
|
| 293 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_coupon'),$cartId);
|
293 |
$_GET['userId'] = $authorized['Id'];
|
| 294 |
$dealTextArray = array();
|
294 |
$_GET['action'] = 'applycoupon';
|
| 295 |
if(!empty($response)){
|
295 |
$cartId = $authorized['cartId'];
|
| 296 |
foreach($response['response']['cartcoupon'][0]->lines AS $line) {
|
296 |
if($authorized['isLoggedIn'] == 1){
|
| 297 |
$dealTextArray[$line->itemId] = $line->dealText;
|
297 |
$_GET['isLoggedIn'] = 'true';
|
| 298 |
}
|
298 |
}
|
| 299 |
}
|
299 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 300 |
$result = $response['response']['cartcoupon'][0];
|
300 |
$_GET['isLoggedIn'] = 'false';
|
| 301 |
if(isset($result->couponCode) && !empty($result->couponCode)){
|
301 |
}
|
| 302 |
$couponCode = $result->couponCode;
|
302 |
}
|
| 303 |
}
|
303 |
if(isset($code) and !empty($code))
|
| 304 |
else{
|
304 |
{
|
| 305 |
$couponCode = '';
|
305 |
//if user logged-in
|
| 306 |
}
|
306 |
$_GET['coupon_code'] = $code;
|
| 307 |
if($result->discountedPrice==0){
|
307 |
//TODO: Move to a config file maybe
|
| 308 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->totalPrice,'message'=>$result->message,'couponCode'=>$couponCode);
|
308 |
if($code=='saholicdeals') {
|
| 309 |
} else {
|
309 |
$this->session->set_userdata('isAutoApplicationOff','false');
|
| 310 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->discountedPrice,'message'=>$result->message,'couponCode'=>$couponCode);
|
310 |
}
|
| 311 |
}
|
311 |
//$d=$this->input->get();
|
| 312 |
$res['dealTextArray']=$dealTextArray;
|
312 |
}
|
| 313 |
echo json_encode($res);
|
313 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_coupon'),$cartId);
|
| 314 |
}
|
314 |
$dealTextArray = array();
|
| 315 |
public function couponClear($code=null)
|
315 |
if(!empty($response)){
|
| 316 |
{
|
316 |
foreach($response['response']['cartcoupon'][0]->lines AS $line) {
|
| 317 |
$response=array();
|
317 |
$dealTextArray[$line->itemId] = $line->dealText;
|
| 318 |
$authorized = $this->session->userdata('authorized');
|
318 |
}
|
| 319 |
$this->session->set_userdata('isAutoApplicationOff','true');
|
319 |
}
|
| 320 |
if(isset($authorized) && !empty($authorized)){
|
320 |
$result = $response['response']['cartcoupon'][0];
|
| 321 |
$_GET['userId'] = $authorized['Id'];
|
321 |
if(isset($result->couponCode) && !empty($result->couponCode)){
|
| 322 |
$_GET['action'] = 'removecoupon';
|
322 |
$couponCode = $result->couponCode;
|
| 323 |
$cartId = $authorized['cartId'];
|
323 |
}
|
| 324 |
if($authorized['isLoggedIn'] == 1){
|
324 |
else{
|
| 325 |
$_GET['isLoggedIn'] = 'true';
|
325 |
$couponCode = '';
|
| 326 |
}
|
326 |
}
|
| 327 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
327 |
if($result->discountedPrice==0){
|
| 328 |
$_GET['isLoggedIn'] = 'false';
|
328 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->totalPrice,'message'=>$result->message,'couponCode'=>$couponCode);
|
| 329 |
}
|
329 |
} else {
|
| 330 |
}
|
330 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->discountedPrice,'message'=>$result->message,'couponCode'=>$couponCode);
|
| 331 |
if(isset($code) and !empty($code))
|
331 |
}
|
| 332 |
{
|
332 |
$res['dealTextArray']=$dealTextArray;
|
| 333 |
//if user logged-in
|
333 |
echo json_encode($res);
|
| 334 |
$_GET['coupon_code'] = $code;
|
334 |
}
|
| 335 |
//$d=$this->input->get();
|
335 |
public function couponClear($code=null)
|
| 336 |
}
|
336 |
{
|
| 337 |
//print_r($this->config->item('cart_couponclear'));
|
337 |
$response=array();
|
| 338 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_couponclear'),$cartId);
|
338 |
$authorized = $this->session->userdata('authorized');
|
| 339 |
$result = $response['response']['cartcouponclear'][0];
|
339 |
$this->session->set_userdata('isAutoApplicationOff','true');
|
| 340 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->discountedPrice,'message'=>$result->message);
|
340 |
if(isset($authorized) && !empty($authorized)){
|
| 341 |
echo json_encode($res);
|
341 |
$_GET['userId'] = $authorized['Id'];
|
| 342 |
}
|
342 |
$_GET['action'] = 'removecoupon';
|
| 343 |
public function cartCount()
|
343 |
$cartId = $authorized['cartId'];
|
| 344 |
{
|
344 |
if($authorized['isLoggedIn'] == 1){
|
| 345 |
$response=array();
|
345 |
$_GET['isLoggedIn'] = 'true';
|
| 346 |
$authorized = $this->session->userdata('authorized');
|
346 |
}
|
| 347 |
$shoppingId =$this->session->userdata('shoppingId');
|
347 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 348 |
if((isset($authorized) and !empty($authorized['id'])) || ((isset($shoppingId) && !empty($shoppingId)))){
|
348 |
$_GET['isLoggedIn'] = 'false';
|
| 349 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_count'));
|
349 |
}
|
| 350 |
if(isset($response['response']['cartcount'][0])){
|
350 |
}
|
| 351 |
$result = $response['response']['cartcount'][0];
|
351 |
if(isset($code) and !empty($code))
|
| 352 |
echo $result;
|
352 |
{
|
| 353 |
}
|
353 |
//if user logged-in
|
| 354 |
else{
|
354 |
$_GET['coupon_code'] = $code;
|
| 355 |
$result = 0;
|
355 |
//$d=$this->input->get();
|
| 356 |
echo $result;
|
356 |
}
|
| 357 |
}
|
357 |
//print_r($this->config->item('cart_couponclear'));
|
| 358 |
}
|
358 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_couponclear'),$cartId);
|
| 359 |
else{
|
359 |
$result = $response['response']['cartcouponclear'][0];
|
| 360 |
$result = 0;
|
360 |
$res = array('totalPrice'=>$result->totalPrice,'discountedPrice'=>$result->discountedPrice,'message'=>$result->message);
|
| 361 |
echo $result;
|
361 |
echo json_encode($res);
|
| 362 |
}
|
362 |
}
|
| 363 |
}
|
363 |
public function cartCount()
|
| 364 |
|
364 |
{
|
| 365 |
public function insure($itemId,$toInsure,$insuranceType){
|
365 |
$response=array();
|
| 366 |
$authorized = $this->session->userdata('authorized');
|
366 |
$authorized = $this->session->userdata('authorized');
|
| 367 |
if(isset($authorized) && !empty($authorized)){
|
367 |
$shoppingId =$this->session->userdata('shoppingId');
|
| 368 |
$_GET['userId'] = $authorized['Id'];
|
368 |
if((isset($authorized) and !empty($authorized['id'])) || ((isset($shoppingId) && !empty($shoppingId)))){
|
| 369 |
$_GET['Id'] = $authorized['cartId'];
|
369 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_count'));
|
| 370 |
if($authorized['isLoggedIn'] == 1){
|
370 |
if(isset($response['response']['cartcount'][0])){
|
| 371 |
$_GET['isLoggedIn'] = 'true';
|
371 |
$result = $response['response']['cartcount'][0];
|
| 372 |
}
|
372 |
echo $result;
|
| 373 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
373 |
}
|
| 374 |
$_GET['isLoggedIn'] = 'false';
|
374 |
else{
|
| 375 |
}
|
375 |
$result = 0;
|
| 376 |
}
|
376 |
echo $result;
|
| 377 |
$_GET['itemId'] = $itemId;
|
377 |
}
|
| 378 |
$_GET['toInsure'] = $toInsure;
|
378 |
}
|
| 379 |
$_GET['insuranceType'] = $insuranceType;
|
379 |
else{
|
| 380 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_insure'));
|
380 |
$result = 0;
|
| 381 |
$insurance = $response['response']['cartinsure'][0]->insuranceResult;
|
381 |
echo $result;
|
| 382 |
if(strcasecmp($insurance, 'success') == 0){
|
382 |
}
|
| 383 |
//$status[0] = true;
|
383 |
}
|
| 384 |
$res = array('status'=>true);
|
384 |
|
| 385 |
echo json_encode($res);
|
385 |
public function insure($itemId,$toInsure,$insuranceType){
|
| 386 |
}
|
386 |
$authorized = $this->session->userdata('authorized');
|
| 387 |
elseif(strcasecmp($insurance, 'failure') == 0) {
|
387 |
if(isset($authorized) && !empty($authorized)){
|
| 388 |
$status[0] = false;
|
388 |
$_GET['userId'] = $authorized['Id'];
|
| 389 |
echo json_encode($status);
|
389 |
$_GET['Id'] = $authorized['cartId'];
|
| 390 |
}
|
390 |
if($authorized['isLoggedIn'] == 1){
|
| 391 |
}
|
391 |
$_GET['isLoggedIn'] = 'true';
|
| 392 |
//improve functinalities using ajax
|
392 |
}
|
| 393 |
public function anonymous()
|
393 |
elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
|
| 394 |
{
|
394 |
$_GET['isLoggedIn'] = 'false';
|
| 395 |
$url = $this->config->item('anonymous');
|
395 |
}
|
| 396 |
$url = $url['url'];
|
396 |
}
|
| 397 |
$url = $this->config->item('curl_base_url').$url;
|
397 |
$_GET['itemId'] = $itemId;
|
| 398 |
$params = array();
|
398 |
$_GET['toInsure'] = $toInsure;
|
| 399 |
$this->mcurl->add_call('anonymous','get',$url,$params);
|
399 |
$_GET['insuranceType'] = $insuranceType;
|
| 400 |
$responses = $this->mcurl->execute($url);
|
400 |
$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_insure'));
|
| 401 |
$response = array();
|
401 |
$insurance = $response['response']['cartinsure'][0]->insuranceResult;
|
| 402 |
if(isset($responses['anonymous']['response']) && !empty($responses['anonymous']['response'])){
|
402 |
if(strcasecmp($insurance, 'success') == 0){
|
| 403 |
$data = json_decode($responses['anonymous']['response']);
|
403 |
//$status[0] = true;
|
| 404 |
$childarray=array();
|
404 |
$res = array('status'=>true);
|
| 405 |
$childarray['Id']=$data->userId;
|
405 |
echo json_encode($res);
|
| 406 |
$childarray['isLoggedIn']=$data->isLoggedIn;
|
406 |
}
|
| 407 |
$childarray['pincode']=$data->pincode;
|
407 |
elseif(strcasecmp($insurance, 'failure') == 0) {
|
| 408 |
$childarray['email']=$data->email;
|
408 |
$status[0] = false;
|
| 409 |
$childarray['totalItems']=$data->totalItems;
|
409 |
echo json_encode($status);
|
| 410 |
$childarray['cartId']=$data->cartId;
|
410 |
}
|
| 411 |
$response['authorized']=$childarray;
|
411 |
}
|
| 412 |
$this->session->set_userdata('authorized',$response['authorized']);
|
412 |
//improve functinalities using ajax
|
| 413 |
}
|
413 |
public function anonymous()
|
| 414 |
return $response;
|
414 |
{
|
| 415 |
}
|
415 |
$url = $this->config->item('anonymous');
|
| 416 |
public function delete_ajax()
|
416 |
$url = $url['url'];
|
| 417 |
{}
|
417 |
$url = $this->config->item('curl_base_url').$url;
|
| 418 |
}
|
418 |
$params = array();
|
| 419 |
|
419 |
$this->mcurl->add_call('anonymous','get',$url,$params);
|
| 420 |
/* End of file welcome.php */
|
420 |
$responses = $this->mcurl->execute($url);
|
| 421 |
/* Location: ./application/controllers/welcome.php */
|
421 |
$response = array();
|
| - |
|
422 |
if(isset($responses['anonymous']['response']) && !empty($responses['anonymous']['response'])){
|
| - |
|
423 |
$data = json_decode($responses['anonymous']['response']);
|
| - |
|
424 |
$childarray=array();
|
| - |
|
425 |
$childarray['Id']=$data->userId;
|
| - |
|
426 |
$childarray['isLoggedIn']=$data->isLoggedIn;
|
| - |
|
427 |
$childarray['pincode']=$data->pincode;
|
| - |
|
428 |
$childarray['email']=$data->email;
|
| - |
|
429 |
$childarray['totalItems']=$data->totalItems;
|
| - |
|
430 |
$childarray['cartId']=$data->cartId;
|
| - |
|
431 |
$response['authorized']=$childarray;
|
| - |
|
432 |
$this->session->set_userdata('authorized',$response['authorized']);
|
| - |
|
433 |
}
|
| - |
|
434 |
return $response;
|
| - |
|
435 |
}
|
| - |
|
436 |
public function delete_ajax()
|
| - |
|
437 |
{}
|
| - |
|
438 |
}
|
| - |
|
439 |
|
| - |
|
440 |
/* End of file welcome.php */
|
| - |
|
441 |
/* Location: ./application/controllers/welcome.php */
|