Subversion Repositories SmartDukaan

Rev

Rev 11924 | Rev 12056 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11924 Rev 12053
Line 33... Line 33...
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'])) {
-
 
39
				$_GET['privateDealUser'] = 'true';
-
 
40
			}
-
 
41
			$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
-
 
42
			$_GET['autoApplicationOff'] = 'false';
-
 
43
			if(isset($isAutoApplicationOff) && !empty($isAutoApplicationOff)) {
-
 
44
				$_GET['autoApplicationOff'] = 'true';
-
 
45
			}
38
			if($authorized['isLoggedIn'] == 1){
46
			if($authorized['isLoggedIn'] == 1){
39
				$_GET['isLoggedIn'] = 'true';
47
				$_GET['isLoggedIn'] = 'true';
40
			}
48
			}
41
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
49
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
42
				$_GET['isLoggedIn'] = 'false';
50
				$_GET['isLoggedIn'] = 'false';
Line 90... Line 98...
90
	public function add($id=null,$email=null,$itemname)
98
	public function add($id=null,$email=null,$itemname)
91
	{
99
	{
92
		$response=array();
100
		$response=array();
93
		
101
		
94
		$authorized = $this->session->userdata('authorized');
102
		$authorized = $this->session->userdata('authorized');
-
 
103
		$isAutoApplicationOff = $this->session->userdata('isAutoApplicationOff');
-
 
104
 
95
		if(isset($id) and !empty($id) and is_numeric($id))
105
		if(isset($id) and !empty($id) and is_numeric($id))
96
			{
106
			{
97
				//if user logged-in
107
				//if user logged-in
98
				$_POST['itemId'] = $id;
108
				$_POST['itemId'] = $id;
99
			}
109
			}
Line 101... Line 111...
101
			redirect(base_url());
111
			redirect(base_url());
102
		}
112
		}
103
		if(isset($authorized) && !empty($authorized)){
113
		if(isset($authorized) && !empty($authorized)){
104
			$_POST['userId'] = $authorized['Id'];
114
			$_POST['userId'] = $authorized['Id'];
105
			$_POST['Id'] = $authorized['cartId'];
115
			$_POST['Id'] = $authorized['cartId'];
-
 
116
			
106
			if($authorized['isLoggedIn'] == 1){
117
			if($authorized['isLoggedIn'] == 1){
107
				$_POST['isLoggedIn'] = 'true';
118
				$_POST['isLoggedIn'] = 'true';
108
			}
119
			}
109
			elseif((isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn']))) {
120
			elseif((isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn']))) {
110
				$_POST['isLoggedIn'] = 'false';
121
				$_POST['isLoggedIn'] = 'false';
Line 145... Line 156...
145
			echo json_encode($response['response']);
156
			echo json_encode($response['response']);
146
			//redirect(base_url().strtolower(__CLASS__),'refresh');
157
			//redirect(base_url().strtolower(__CLASS__),'refresh');
147
		}elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl != 'cart'){
158
		}elseif(isset($response['response']['addcart'][0]->redirectUrl) && $response['response']['addcart'][0]->redirectUrl != 'cart'){
148
			echo json_encode($response['response']);
159
			echo json_encode($response['response']);
149
		}
160
		}
-
 
161
		print_r($response);
150
	}
162
	}
151
	public function update($id=null,$qty=null)
163
	public function update($id=null,$qty=null)
152
	{
164
	{
153
		$response=array();
165
		$response=array();
154
		$authorized = $this->session->userdata('authorized');
166
		$authorized = $this->session->userdata('authorized');
Line 243... Line 255...
243
		}
255
		}
244
		if(isset($code) and !empty($code))
256
		if(isset($code) and !empty($code))
245
		{
257
		{
246
			//if user logged-in
258
			//if user logged-in
247
			$_GET['coupon_code'] = $code;
259
			$_GET['coupon_code'] = $code;
-
 
260
			//TODO: Move to a config file maybe
-
 
261
			if($code=='saholicdeals') {
-
 
262
				$this->session->set_userdata('isAutoApplicationOff','false');
-
 
263
			}
248
			//$d=$this->input->get();
264
			//$d=$this->input->get();
249
			}
265
			}
250
		$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_coupon'),$cartId);
266
		$response=$this->cart_model->getCart($this->input->get(),$this->input->post(),$this->config->item('cart_coupon'),$cartId);
251
		$dealTextArray = array();
267
		$dealTextArray = array();
252
		if(!empty($response)){			
268
		if(!empty($response)){			
Line 271... Line 287...
271
	}
287
	}
272
	public function couponClear($code=null)
288
	public function couponClear($code=null)
273
	{
289
	{
274
		$response=array();
290
		$response=array();
275
		$authorized = $this->session->userdata('authorized');
291
		$authorized = $this->session->userdata('authorized');
-
 
292
		$this->session->set_userdata('isAutoApplicationOff','true');
276
		if(isset($authorized) && !empty($authorized)){
293
		if(isset($authorized) && !empty($authorized)){
277
		    $_GET['userId'] = $authorized['Id'];
294
		    $_GET['userId'] = $authorized['Id'];
278
			$_GET['action'] = 'removecoupon';
295
			$_GET['action'] = 'removecoupon';
279
			$cartId = $authorized['cartId'];
296
			$cartId = $authorized['cartId'];
280
			if($authorized['isLoggedIn'] == 1){
297
			if($authorized['isLoggedIn'] == 1){