Subversion Repositories SmartDukaan

Rev

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

Rev 20885 Rev 20978
Line 46... Line 46...
46
		}
46
		}
47
		
47
		
48
		$cartItems = array();
48
		$cartItems = array();
49
		
49
		
50
		foreach ($dataGiven->cartItems as $key=>$obj) {
50
		foreach ($dataGiven->cartItems as $key=>$obj) {
51
		    $itemobj = array(
-
 
52
					'itemId'   => $key,
-
 
53
		    		'quantity' => $obj->quantity);
51
		    $itemobj = array('itemId'   => $key, 'quantity' => $obj->quantity);
54
			array_push($cartItems, $itemobj);
52
			array_push($cartItems, $itemobj);
55
		}
53
		}
56
		$postData = array(
-
 
57
					'cartItems'	=>	$cartItems
54
		$postData = array('cartItems'	=>	$cartItems);
58
					);
-
 
59
					
-
 
60
		$params = array(
-
 
61
				'cartMap' => urlencode(json_encode($postData)));
55
		$params = array('cartMap' => urlencode(json_encode($postData)));
62
		
56
		
63
		$this->layout = 'cartinnerpages';
57
		$this->layout = 'cartinnerpages';
64
		$url = Configure::read('saholicapihost').'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId;
58
		$url = Configure::read('saholicapihost').'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId;
65
		if($pincode!='0'){
59
		if($pincode!='0'){
66
			$url = $url.'&pinCode='.$pincode;
60
			$url = $url.'&pinCode='.$pincode;
Line 241... Line 235...
241
		if ($getstate != "{}") {
235
		if ($getstate != "{}") {
242
			$getstateval = ucwords ( strtolower ( $getstate ['state'] ) );
236
			$getstateval = ucwords ( strtolower ( $getstate ['state'] ) );
243
		}
237
		}
244
		$this->set(compact('getstateval', 'user_name', 'user_contact', 'pinval', 'totalPayable', 'codAvailable', 'taxInvoiceEnabledUser', 'walletAmount'));
238
		$this->set(compact('getstateval', 'user_name', 'user_contact', 'pinval', 'totalPayable', 'codAvailable', 'taxInvoiceEnabledUser', 'walletAmount'));
245
	}
239
	}
-
 
240
	
-
 
241
	
246
	public function submitcheck() {
242
	public function submitcheck() {
247
		$this->autoRender = false;
243
		$this->autoRender = false;
248
		$this->request->onlyAllow ( 'ajax' );
244
		$this->request->onlyAllow ( 'ajax' );
249
		
245
		
250
		$suserId = base64_decode($_COOKIE['s_id']);
246
		$suserId = base64_decode($_COOKIE['s_id']);
Line 259... Line 255...
259
		$senddata ['city'] = $data ['city'];
255
		$senddata ['city'] = $data ['city'];
260
		$senddata ['state'] = $data ['state'];
256
		$senddata ['state'] = $data ['state'];
261
		$senddata ['pin'] = $data ['pin'];
257
		$senddata ['pin'] = $data ['pin'];
262
		$senddata ['phone'] = $data ['phone'];
258
		$senddata ['phone'] = $data ['phone'];
263
		$senddata ['country'] = 'India';
259
		$senddata ['country'] = 'India';
-
 
260
		setcookie('s_pincode', base64_encode($data['pin']), -1, '/');
264
		$url = Configure::read ( 'saholicapihost' ) . "address?userId=" . $suserId . "&isLoggedIn=true&cartId=" . $scartId . "&isPrivateDealUser=true";
261
		$url = Configure::read ( 'saholicapihost' ) . "address?userId=" . $suserId . "&isLoggedIn=true&cartId=" . $scartId . "&isPrivateDealUser=true";
265
		
262
		
266
		$response = $this->post_cartinfo_request($url,$senddata);
263
		$response = $this->post_cartinfo_request($url,$senddata);
267
		$suserId = base64_decode ( $_COOKIE ['s_id'] );
264
		$suserId = base64_decode ( $_COOKIE ['s_id'] );
268
		
265
		
269
		$scartId = base64_decode ( $_COOKIE ['s_cart'] );
266
		$scartId = base64_decode ( $_COOKIE ['s_cart'] );
270
		$semailId = base64_decode ( $_COOKIE ['s_email'] );
267
		$semailId = base64_decode ( $_COOKIE ['s_email'] );
-
 
268
 
271
		$blank = array ();
269
		$cartItems = array();
-
 
270
		foreach (json_decode($data['cart_details'])->cartItems as $key=>$obj) {
272
		$postData = array (
271
		    $itemobj = array('itemId'   => $key, 'quantity' => $obj->quantity);
273
				'cartItems' => $blank 
272
			array_push($cartItems, $itemobj);
274
		);
-
 
275
		
273
		}
276
		$params = array (
274
		$postData = array('cartItems'	=>	$cartItems);
277
				'cartMap' => urlencode ( json_encode ( $postData ) ) 
275
		$params = array('cartMap' => urlencode(json_encode($postData)));
278
		);
276
		
279
		$url = Configure::read ( 'saholicapihost' ) . 'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId=' . $suserId . '&id=' . $scartId . '&email=' . $semailId;
277
		$url = Configure::read ( 'saholicapihost' ) . 'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId=' . $suserId . '&id=' . $scartId . '&email=' . $semailId;
280
		// if($pin!='0'){
-
 
281
		$url = $url . '&pinCode=' . $data ['pin'];
278
		$url = $url . '&pinCode=' . $data ['pin'];
282
		// }
-
 
283
		$cartskus = $this->post_cartinfo_request ( $url, $params );
279
		$cartskus = $this->post_cartinfo_request ( $url, $params );
-
 
280
 
284
		$checkestimate = $response ['defaultAddress'];
281
		$checkestimate = $response ['defaultAddress'];
285
		if ($cartskus ['maxEstimate'] == - 1) {
282
		if (count($cartskus['cartMessages'])>0) {
286
			$checkestimate = '';
-
 
287
		} 
-
 
288
		else if ($cartskus ['maxEstimate'] == - 2) {
-
 
289
			$checkestimate = 'non_service';
283
			$checkestimate = 'cart_redirect';
290
		} else {
-
 
291
			for($i = 0; $i < count ( $cartskus ['cartItems'] ); $i ++) {
-
 
292
				if(array_key_exists('estimate',$cartskus ['cartItems'] [$i])){
-
 
293
					continue;
-
 
294
				}
-
 
295
				$estimate = $cartskus ['cartItems'] [$i] ['estimate'];
-
 
296
				if ($estimate==-1) {
-
 
297
					$checkestimate = '';
-
 
298
					break;
-
 
299
				}
-
 
300
			}
-
 
301
		}
284
		}
-
 
285
		return $checkestimate;
-
 
286
	}
-
 
287
	
-
 
288
	public function isServicable($pin) {
-
 
289
		$this->autoRender = false;
-
 
290
		$this->request->onlyAllow ( 'ajax' );
-
 
291
		$data = $this->request->data;
-
 
292
		$scartId = base64_decode ( $_COOKIE ['s_cart'] );
-
 
293
		$suserId = base64_decode ( $_COOKIE ['s_id'] );
-
 
294
		$semailId = base64_decode ( $_COOKIE ['s_email'] );
-
 
295
		setcookie('s_pincode', base64_encode($pin), -1, '/');
-
 
296
		
-
 
297
		$cartItems = array();
-
 
298
		foreach (json_decode($data['cart_details'])->cartItems as $key=>$obj) {
-
 
299
		    $itemobj = array('itemId'   => $key, 'quantity' => $obj->quantity);
-
 
300
			array_push($cartItems, $itemobj);
-
 
301
		}
-
 
302
		$postData = array('cartItems'	=>	$cartItems);
-
 
303
		$params = array('cartMap' => urlencode(json_encode($postData)));
302
		
304
		
-
 
305
		$url = Configure::read ( 'saholicapihost' ) . 'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId=' . $suserId . '&id=' . $scartId . '&email=' . $semailId;
-
 
306
		$url = $url . '&pinCode=' . $pin;
-
 
307
		$cartskus = $this->post_cartinfo_request ( $url, $params );
-
 
308
		
-
 
309
		if($cartskus['maxEstimate']==-1){
-
 
310
			$checkestimate = 'non_service';
-
 
311
		}
-
 
312
		else if (count($cartskus['cartMessages'])>0) {
-
 
313
			$checkestimate = 'cart_redirect';
-
 
314
		} else if ($cartskus['maxEstimate']>=0) {
-
 
315
			$checkestimate = 'ok';
-
 
316
		}
303
		return $checkestimate;
317
		return $checkestimate;
304
	}
318
	}
-
 
319
	
305
	public function getstate($pin_val) {
320
	public function getstate($pin_val) {
306
		$this->autoRender = false;
321
		$this->autoRender = false;
307
		$this->request->onlyAllow ( 'ajax' );
322
		$this->request->onlyAllow ( 'ajax' );
308
		$url = $this->apihost . "pincodeValidation/" . $pin_val;
323
		$url = $this->apihost . "pincodeValidation/" . $pin_val;
309
		$getstate = $this->make_request ( $url, null );
324
		$getstate = $this->make_request ( $url, null );
Line 312... Line 327...
312
		if ($getstate != "{}") {
327
		if ($getstate != "{}") {
313
			$getstate ['state'] = ucwords ( strtolower ( $getstate ['state'] ) );
328
			$getstate ['state'] = ucwords ( strtolower ( $getstate ['state'] ) );
314
		}
329
		}
315
		return json_encode ( $getstate );
330
		return json_encode ( $getstate );
316
	}
331
	}
317
	public function isServicable($pin) {
-
 
318
		$this->autoRender = false;
-
 
319
		$this->request->onlyAllow ( 'ajax' );
-
 
320
		// $url = "http://shop2020.in:8080/mobileapi/address!serviceable?pincode=".$pin;
-
 
321
		// $response = $this->make_request($url,null);
-
 
322
		
-
 
323
		$scartId = base64_decode ( $_COOKIE ['s_cart'] );
-
 
324
		$suserId = base64_decode ( $_COOKIE ['s_id'] );
-
 
325
		$semailId = base64_decode ( $_COOKIE ['s_email'] );
-
 
326
		$blank = array ();
-
 
327
		$postData = array (
-
 
328
				'cartItems' => $blank 
-
 
329
		);
-
 
330
		
-
 
331
		$params = array (
-
 
332
				'cartMap' => urlencode ( json_encode ( $postData ) ) 
-
 
333
		);
-
 
334
		$url = Configure::read ( 'saholicapihost' ) . 'cart!validateCart?isLoggedIn=true&privateDealUser=true&userId=' . $suserId . '&id=' . $scartId . '&email=' . $semailId;
-
 
335
		$url = $url . '&pinCode=' . $pin;
-
 
336
		$cartskus = $this->post_cartinfo_request ( $url, $params );
-
 
337
		$checkestimate = 'true';
-
 
338
		if ($cartskus ['maxEstimate'] == -1) {
-
 
339
			$checkestimate = 'false';
-
 
340
		} 
-
 
341
		else if ($cartskus ['maxEstimate'] == -2) {
-
 
342
			$checkestimate = 'false';
-
 
343
		} 
-
 
344
		else {
-
 
345
			for($i = 0; $i < count ( $cartskus ['cartItems'] ); $i ++) {
-
 
346
				if(array_key_exists('estimate',$cartskus ['cartItems'] [$i])){
-
 
347
					continue;
-
 
348
				}
-
 
349
				$estimate = $cartskus ['cartItems'] [$i] ['estimate'];
-
 
350
				if ($estimate==-1) {
-
 
351
					$checkestimate = 'false';
-
 
352
					break;
-
 
353
				}
-
 
354
			}
-
 
355
		}
-
 
356
		
332
	
357
		return $checkestimate;
-
 
358
	}
333
	
359
	
334
	
360
	 public function checkout(){
335
	 public function checkout(){
361
	 	$addressid = $this->request->data['addressid'];
336
	 	$addressid = $this->request->data['addressid'];
362
	 	$pincode = 0;
337
	 	$pincode = 0;
363
		$cod = $this->request->query('cod');
338
		$cod = $this->request->query('cod');