Subversion Repositories SmartDukaan

Rev

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

Rev 17766 Rev 17804
Line 973... Line 973...
973
		}		
973
		}		
974
		return $links[$categoryId];		
974
		return $links[$categoryId];		
975
	}
975
	}
976
	
976
	
977
	public function cartdetails(){
977
	public function cartdetails(){
-
 
978
		
978
		$postData = json_decode($this->request->data['cart_details']);
979
		$dataGiven = json_decode($this->request->data['cart_details']);
-
 
980
		$pincode = $this->request->data['pincode'];
979
		$userId = $this->request->query('user_id');
981
		$userId = $this->request->query('user_id');
980
		
982
		
-
 
983
		if(!isset($pincode)){
-
 
984
			$pincode = 0;
-
 
985
		}
-
 
986
		if($pincode==0 && isset($_COOKIE['s_pincode'])){
-
 
987
			$pincode = base64_decode($_COOKIE['s_pincode']);
-
 
988
		}
-
 
989
		$suserId = 0;
-
 
990
		$scartId = 0;
-
 
991
		$semailId = '';
-
 
992
		
-
 
993
		if(!(isset($_COOKIE['s_cart']))) {
-
 
994
			$this->loadModel('UserAccount');
981
		$options = array('contain'=>array('UserAccount'), 'conditions'=>array('User.id'=>$userId,'UserAccount.account_type'=>'saholic'),'fields'=>array('username','email','key'),'recursive'=>-1);
995
			$options = array('conditions'=>array('user_id'=>$userId,'account_type'=>'cartId'),'recursive'=>-1,'fields'=>'account_key');
982
		$user = $this->User->find('first',$options);
996
			$cartId = $this->UserAccount->find('first',$options);
-
 
997
			$scartId = $cartId['UserAccount']['account_key'];
-
 
998
			setcookie('s_cart', base64_encode($scartId), -1, '/');
-
 
999
		}else{
-
 
1000
			$scartId = base64_decode($_COOKIE['s_cart']);
983
		/*
1001
		}
-
 
1002
		if(!(isset($_COOKIE['s_id']))){
-
 
1003
			$this->loadModel('UserAccount');
984
		$options = array('conditions'=>array('user_id'=>$userId,'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'account_key');
1004
			$options = array('conditions'=>array('user_id'=>$userId,'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'account_key');
985
		$userAccount = $this->UserAccount->find('first',$options);
1005
			$userAccount = $this->UserAccount->find('first',$options);
-
 
1006
			$suserId = $userAccount['UserAccount']['account_key'];
-
 
1007
			setcookie('s_id', base64_encode($suserId), -1, '/');
-
 
1008
		}else{
-
 
1009
			$suserId = base64_decode($_COOKIE['s_id']);
-
 
1010
		}
-
 
1011
		if(!(isset($_COOKIE['s_email']))){
-
 
1012
			$this->loadModel('User');
986
		$options = array('conditions'=>array('user_id'=>$userId,'account_type'=>'cartId'),'recursive'=>-1,'fields'=>'account_key');
1013
			$options = array('contain'=>array('UserAccount'), 'conditions'=>array('User.id'=>$userId),'fields'=>array('username','email'),'recursive'=>-1);
987
		$cartId = $this->UserAccount->find('first',$options);
1014
			$user = $this->User->find('first',$options);
-
 
1015
			$semailId = $user['User']['email'];
-
 
1016
			setcookie('s_email', base64_encode($user['User']['email']), -1, '/');
-
 
1017
		}else{
-
 
1018
			$semailId = base64_decode($_COOKIE['s_email']);
-
 
1019
		}
-
 
1020
		
988
		print_r($userAccount);*/
1021
		$cartItems = array();
-
 
1022
		
-
 
1023
		foreach ($dataGiven->cartItems as $key=>$obj) {
-
 
1024
		    $itemobj = array(
-
 
1025
					'itemId'   => $key,
-
 
1026
		    		'quantity' => $obj->quantity);
-
 
1027
			array_push($cartItems, $itemobj);
-
 
1028
		}
-
 
1029
		$postData = array(
-
 
1030
					'cartItems'	=>	$cartItems
-
 
1031
					);
-
 
1032
					
-
 
1033
		$params = array(
-
 
1034
				'cartMap' => urlencode(json_encode($postData)));
-
 
1035
		
-
 
1036
		$this->layout = 'cartinnerpages';
-
 
1037
		$url = Configure::read('saholicapihost').'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId;
989
		#print_r($user);
1038
		if($pincode!='0'){
-
 
1039
			$url = $url.'&pinCode='.$pincode;
-
 
1040
		}
-
 
1041
		
-
 
1042
		$cartskus = $this->post_cartinfo_request($url,$params);
-
 
1043
		
-
 
1044
		if($cartskus['response']=='error'){
-
 
1045
			if (strpos($this->referer(), '&error=1') !== false){
-
 
1046
				$this->redirect($this->referer());
-
 
1047
			}else{
-
 
1048
				$this->redirect($this->referer().'&error=1');
-
 
1049
			}
-
 
1050
			#$this->redirect(array('controller' => 'deals', 'action' => '?user_id='.$userId.'&error=1'));
-
 
1051
		}else{
-
 
1052
			setcookie('s_pincode', base64_encode($cartskus['pincode']), -1, '/');
-
 
1053
			$this->set(compact('cartskus'));
-
 
1054
		}
-
 
1055
		#$this->render('/Users/cartdetailsa');
-
 
1056
		
990
	}
1057
	}
991
}
1058
}