MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b2680/childrendccom.domain.com/
File Upload :
Current < : /hermes/sb_web/b2680/childrendccom.domain.com/guest-checkout.php

<?php
session_start();
include("includes/database.php");
include("functions/functions.php");

include("count.php");
hit_count();
?>
<!doctype html>
<html lang="en">
<head>
<title>Guest Checkout | <?php echo $page_title; ?></title>
<meta name="keywords" content="<?php echo $website_keywords; ?>" />
<meta name="description" content="<?php echo $website_description; ?>" />
<?php include("includes/head.php"); ?>
<style>
.grBG{
    background-color: rgba(0,0,0,0.05);
}
</style>
</head>
<body>
<div class="main-wrapper">
	
	<?php include("includes/header-2.php"); ?>
        
	<!-- breadcrumb-area start -->
	<div class="breadcrumb-area">
		<div class="container">
			<div class="row">
				<div class="col-12">
					<!-- breadcrumb-list start -->
					<ul class="breadcrumb-list">
						<!--<li class="breadcrumb-item"><a href="./">Home</a></li>-->
						<li class="breadcrumb-item active">Guest Checkout</li>
					</ul>
					<!-- breadcrumb-list end -->
				</div>
			</div>
		</div>
	</div>
	<!-- breadcrumb-area end -->
	
	<?php

		$ip = getIp();
		$query_cart = "select * from cart where ip_address = '$ip' AND customer_user_agent = '$customa_user_agent_id'";
		$run_cartq = mysqli_query($con, $query_cart);
		$check_cart = mysqli_num_rows($run_cartq);
		
		if($check_cart > 0){
	?>
	
	<!-- main-content-wrap start -->
	<div class="main-content-wrap section-ptb cart-page">
		<div class="container-fluid">
			<div class="row">
				<div class="col-12 col-lg-8 col-md-8">
					
					<div class="table-content table-responsive">
						<input type="hidden" id="sendCustEm" value="<?php echo $grb_cst_email; ?>" />
						
						<?php
							if(!isset($_SESSION["customer_email"])){
								echo "<div id='cart_body'></div>";
							}else{
								echo "<div id='shopping_cart_body'></div>";
							}
						?>
					</div>
					
					<br />
					
					<!--<button class="btn btn-success" id="empty_cart">EMPTY SHOPPING CART</button> &nbsp; &nbsp; &nbsp;
					
					<a href="home" class="btn btn-success" style="color: #fff;">CONTINUE SHOPPING</a> &nbsp; &nbsp; &nbsp;-->
					
					<?php
						
						$ip = getIp();
						$query_cart = "select * from cart where ip_address = '$ip' AND customer_user_agent = '$customa_user_agent_id'";
						$run_cartq = mysqli_query($con, $query_cart);
						$check_cart = mysqli_num_rows($run_cartq);
						$custIDEF = "1";
						
						if($check_cart > 0){
							
							if(isset($_SESSION["customer_email"])){
								
								$actLocQuery = "select * from customers where customer_email = '$grb_cst_email'";
								$run_actLocQuery = mysqli_query($con, $actLocQuery);
								$row_actLocQuery = mysqli_fetch_array($run_actLocQuery);
								
								$custIDEF = $row_actLocQuery["customer_id"];
								$actLocVal = $row_actLocQuery["actual_location"];
								$custAddrVal = $row_actLocQuery["customer_address"];
								
								echo "
									<hr />
									
									<table class='table table-striped'>
										<tr>
											<th style='width: 65%'>Delivery Address <span style='color: red;'>*</span></th>
											<th style='width: 35%'>Select Emirate <span style='color: red;'>*</span></th>
										</tr>
										<tr>
											<td>
												<input type='text' class='form-control' value='$custAddrVal' id='addressVal' placeholder='Delivery Location Goes Here' />
												<small>Include Building Name / Flat No. / Area Name</small>
											</td>
											<td>
												<select id='actualLocVal' class='form-control control3'>
													<option value='$actLocVal'>$actLocVal</option>
													<option value='Abu Dhabi'>Abu Dhabi</option>
													<option value='Ajman'>Ajman</option>
													<option value='Dubai'>Dubai</option>
													<option value='Fujairah'>Fujairah</option>
													<option value='Ras Al Khaimah'>Ras Al Khaimah</option>
													<option value='Sharjah'>Sharjah</option>
													<option value='Umm Al Quwain'>Umm Al Quwain</option>
												</select>
											</td>
										</tr>
										<!--<tr>
											<td align='right'><button id='update_address' class='btn btn-default'>Update Delivery Address</button></td>
											<td align='right'><button id='update_actual_location' class='btn btn-default'>Update Actual Location</button></td>
										</tr>-->
										<tr>
											<td colspan='2'><button class='btn btn-default proBtn' >CHECKOUT</button></td>
										</tr>
									</table><hr />
								";
								
							}else{
								
							}
							
						}else{
							$custIDEF = "1";
							echo "
								<a href='online-shopping' class='btn btn-default'>SELECT PRODUCT</a>
							";
						}
					
					?>
					
				</div>
				
				<div class="col-12 col-lg-4 col-md-4">
					<div class="shadow radius-image p-4">
						<h2>Order Now</h2>
						<p>Kindly fill up this form if you don't have an account with us.</p>
						<p>Already have an account? <a href="checkout" style="color: #007bff;font-weight: 600;">Sign In</a></p>
						<p>Don't have an account? <a href="register" style="color: #007bff;font-weight: 600;">Sign Up</a></p>
						<hr />
						<form action="" method="POST">
							<div class="form-group">
								<label>Name</label>
								<input type="text" class="form-control" onkeyup="lettersOnly(this)" id="guestName" placeholder="Your Full Name">
							</div><hr />
							
							<div class="form-group">
								<label>Mobile Number</label>
								<div class="input-group mb-2">
									<div class="input-group-prepend">
										<div class="input-group-text"><img src="images/AE-flag.png" width="22" /> &nbsp; +971</div>
									</div>
									<input type="tel" class="form-control" pattern="[0-9]{9}" onkeyup='numbersOnly(this)' id="guestMobile" placeholder="Mobile Number" />
									<input type="hidden" id="w3lhidden" />
								</div>
							</div><hr />
							
							<div class="form-group">
								<label>Email Address</label>
								<input type="email" class="form-control" id="guestEmail" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="Your Email Address">
							</div><hr />
							
							<div class="form-group">
								<label>Emirates</label>
								<select class="form-control" id="guestCity">
									<option value="null">Please Select Emirate</option>
									<option value="Dubai">Dubai</option>
									<option value="Abu Dhabi">Abu Dhabi</option>
									<option value="Al Ain">Al Ain</option>
									<option value="Sharjah">Sharjah</option>
									<option value="Fujairah">Fujairah</option>
									<option value="Ras Al Khaimah">Ras Al Khaimah</option>
									<option value="Umm Al Quwain">Umm Al Quwain</option>
									<option value="Ajman">Ajman</option>
								</select>
							</div><hr />
							
							<div class="form-group">
								<label>Full Address</label>
								<input type="text" class="form-control" onkeyup="lettersOnly(this)" id="guestAddress" placeholder="Your Full Address">
								<small>Include Building Name / Flat No. / Villa No. / Area Name</small>
							</div><hr />
							
							<button type="submit" class="btn btn-default" id="guest_checkout">Buy Now</button>
						</form>
						<script type="text/javascript">
							$(document).ready(function(){
								
								$("body").delegate("#guest_checkout","click",function(e){
									
									e.preventDefault();
									var guestName = $("#guestName").val();
									var guestMobile = $("#guestMobile").val();
									var guestEmail = $("#guestEmail").val();
									var guestCity = $("#guestCity").val();
									var guestAddress = $("#guestAddress").val();
									var guestCoupon = $("#guestCoupon").val();
									var hiddenInput = $("#w3lhidden").val();
									
									if(guestName == "" || guestMobile == "" || guestEmail == "" || guestCity == "null" || guestAddress == ""){
										swal({
										  title: "Please Provide All The Necessary Information, Thanks!",
										  text: "Thanks for Using The Watchtower!",
										  icon: "warning",
										  button: "Click to Continue!",
										});
									}else if(hiddenInput != ""){
										
									}else if(IsEmail(guestEmail)==false){
										swal({
										  title: "Please Provide A Valid Email Address!",
										  text: "Thanks for Using The Watchtower!",
										  icon: "warning",
										  button: "Click to Continue!",
										});
										return false;
									}else{
										$.ajax({
											type:"POST",
											url:"guestAccountCreateData.php",
											data: { send_guestName:guestName, send_guestMobile:guestMobile, send_guestEmail:guestEmail, send_guestCity:guestCity, send_guestAddress:guestAddress },
											success:function(new_entry){
												if(new_entry == "double-email"){
													swal({
													  title: "It Seems You Already Have An Account With Us, Login Instead!",
													  text: "Thanks for Using The Watchtower!",
													  icon: "warning",
													  button: "Click to Continue!",
													});
													setTimeout(function(){
														window.location.href = "checkout?user-email="+guestEmail;
													}, 2500);
												}else if(new_entry == "success"){
													swal({
													  title: "Thanks For Shopping With Us!",
													  text: "Thanks for Using The Watchtower!",
													  icon: "success",
													  button: "Click to Continue!",
													});
													setTimeout(function(){
														//window.location.href = "https://www.zetongifts.com/confirm-order.php";
														window.location.href = "confirm-order";
													}, 2500);
												}else{
													swal({
													  title: new_entry,
													  text: "Thanks for Using The Watchtower!",
													  icon: "success",
													  button: "Click to Continue!",
													});
												}
											}
										});
									}
									
								});
								
								function IsEmail(email){
									var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
									if(!regex.test(email)) {
										return false;
									}else{
										return true;
									}
								}
								
							});
						</script>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- main-content-wrap end -->
	
	<?php
		}else{
			echo "
				<br><br><br>
				<center><a href='index.php' class='btn btn-default'><h3>PLEASE SELECT A PRODUCT</h3></a></center>
				<br><br><br>
			";
		}
	
	?>

<script>
$(document).ready(function(){
	
	
	var actLocationVal = $("#actualLocVal").val();
	var addrVal = $("#addressVal").val();
	
	if(addrVal == "" || actLocationVal == ""){
		$('.proBtn').attr('disabled', true);
	}else{
		$('.proBtn').attr('disabled', false);
	}
	
	$("#update_address").click(function(){
		var custID = <?php echo $custIDEF; ?>;
		var actLocationVal = $("#actualLocVal").val();
		var addrVal = $("#addressVal").val();
		
		if(addrVal == ""){
			swal({
			  title: "Please Provide A Delivery Address!",
			  text: "Thanks for Using The Watchtower!",
			  icon: "warning",
			  button: "Continue!",
			});
			$('.proBtn').attr('disabled', true);
		}else if(actLocationVal == ""){
			swal({
			  title: "Please Provide An Actual Delivery Location!",
			  text: "Thanks for Using The Watchtower!",
			  icon: "warning",
			  button: "Continue!",
			});
			$('.proBtn').attr('disabled', true);
		}else{
			$.ajax({
				type:"POST",
				url:"addressUpdateData.php",
				data: { send_custID:custID, send_addrVal:addrVal, send_actLocationVal:actLocationVal },
				success:function(new_entry){
					swal({
					  title: new_entry,
					  text: "Thanks for Using The Watchtower!",
					  icon: "success",
					  button: "Continue!",
					});
					$('.proBtn').attr('disabled', false);
				}
			});
		}
	});
	
	$("#update_actual_location").click(function(){
		var custID = <?php echo $custIDEF; ?>;
		var actLocationVal = $("#actualLocVal").val();
		var addrVal = $("#addressVal").val();
		
		if(addrVal == ""){
			swal({
			  title: "Please Provide A Delivery Address!",
			  text: "Thanks for Using The Watchtower!",
			  icon: "warning",
			  button: "Continue!",
			});
			$('.proBtn').attr('disabled', true);
		}else if(actLocationVal == ""){
			swal({
			  title: "Please Provide An Actual Delivery Location!",
			  text: "Thanks for Using The Watchtower!",
			  icon: "warning",
			  button: "Continue!",
			});
			$('.proBtn').attr('disabled', true);
		}else{
			$.ajax({
				type:"POST",
				url:"addressUpdateData.php",
				data: { send_custID:custID, send_addrVal:addrVal, send_actLocationVal:actLocationVal },
				success:function(new_entry){
					swal({
					  title: new_entry,
					  text: "Thanks for Using The Watchtower!",
					  icon: "success",
					  button: "Continue!",
					});
					$('.proBtn').attr('disabled', false);
				}
			});
		}
	});
	
	function incrementValue(e) {
		e.preventDefault();
		var fieldName = $(e.target).data('field');
		var parent = $(e.target).closest('div');
		var currentVal = parseInt(parent.find('input[name=' + fieldName + ']').val(), 10);
		if (!isNaN(currentVal)) {
			parent.find('input[name=' + fieldName + ']').val(currentVal + 1);
		} else {parent.find('input[name=' + fieldName + ']').val(1);}
	}
	function decrementValue(e) {
		e.preventDefault();
		var fieldName = $(e.target).data('field');
		var parent = $(e.target).closest('div');
		var currentVal = parseInt(parent.find('input[name=' + fieldName + ']').val(), 10);

		if (!isNaN(currentVal) && currentVal > 1) {
			parent.find('input[name=' + fieldName + ']').val(currentVal - 1);
		} else {parent.find('input[name=' + fieldName + ']').val(1);}
	}
	
	function total_price(){
		//alert("total price");
		$.ajax({
			url:		"action.php",
			method:		"POST",
			data:		{total_price:1},
			success:	function(data){
				$(".total_price").html(data);
			}
		});
	}
	
	$("body").delegate(".button-plus","click",function(evBtn){
		evBtn.preventDefault();
		incrementValue(evBtn);
		var pid = $(this).attr("pid");
		var qty = $("#qty-"+pid).val();
		var price = $("#price-"+pid).val();
		var total = qty * price;
		$("#total-"+pid).val(total);
		$.ajax({
			url:		"action.php",
			method:		"POST",
			data:		{update_item:1,pro_id:pid,quantity:qty,prod_price:price,total_amt:total},
			success:	function(evData){
				//alert("plus");
				total_price()
			}
		});
	});
	
	$("body").delegate(".button-minus","click",function(evBtn){
		evBtn.preventDefault();
		//alert("working");
		decrementValue(evBtn);
		var pid = $(this).attr("pid");
		var qty = $("#qty-"+pid).val();
		var price = $("#price-"+pid).val();
		var total = qty * price;
		$("#total-"+pid).val(total);
		$.ajax({
			url:		"action.php",
			method:		"POST",
			data:		{update_item:1,pro_id:pid,quantity:qty,prod_price:price,total_amt:total},
			success:	function(evData){
				//alert("minus");
				total_price()
			}
		});
	});
	
});
</script>

<?php include("includes/footer.php"); ?>
</body>
</html>