<?php
$cstEmail = $_SESSION["customer_email"];
$query_cstEmail = "select * from customers where customer_address = '' AND actual_location = '' AND customer_email = '$cstEmail'";
$run_cstEmail = mysqli_query($con, $query_cstEmail);
$check_cstEmail = mysqli_num_rows($run_cstEmail);
if($check_cstEmail == 1){
header("Location: shopping-cart");
exit();
}else{
?>
<div class="banner_bottom_agile_info"><br>
<div class="container">
<div class="agile_ab_w3ls_info">
<div class="inner_sec_info_wthree_agile">
<div class="signin-form">
<div class="login-form-rec">
<center><h3>Payment Options</h3></center>
<div class="row">
<?php
include("includes/database.php");
$us_ip = getIp();
$grb_cst_email = $_SESSION["customer_email"];
//getting the delivery rate
$delivery_rate = 0;
$deducVal = 0;
$get_cust = "select * from customers where customer_ip = '$us_ip' AND customer_user_agent = '$customa_user_agent_id' AND customer_email = '$grb_cst_email'";
$run_cust = mysqli_query($con, $get_cust);
$row_cust = mysqli_fetch_array($run_cust);
$customer_id = $row_cust["customer_id"];
$customer_email = $row_cust["customer_email"];
$cust_location = $row_cust['customer_location'];
$cust_name = $row_cust['customer_name'];
$cust_email = $row_cust['customer_email'];
$cust_address = $row_cust['customer_address'];
$cust_phone = $row_cust['customer_phone'];
//getting product price & number of items
$total = 0;
$status = "Pending";
$invoice_no = time();
$sel_price = "select * from cart where ip_address = '$us_ip' AND customer_user_agent = '$customa_user_agent_id'";
$run_price = mysqli_query($con, $sel_price);
$count_pro_price = mysqli_num_rows($run_price);
if($cust_location == "inside_region" && $count_pro_price >= 1){
$delivery_rate = $wiz_rate_ins;
}else if($cust_location == "outside_region" && $count_pro_price >= 1){
$delivery_rate = $wiz_rate_out;
}else if($cust_location == "outside_country" && $count_pro_price >= 1){
$delivery_rate = $wiz_rate_intl;
}else{
$delivery_rate = 0;
}
while($row_p = mysqli_fetch_array($run_price)){
$prod_id = $row_p['product_id'];
$prod_qty = $row_p['quantity'];
$prod_price = "select * from product where product_id = '$prod_id'";
$run_pro_price = mysqli_query($con, $prod_price);
while($row_price = mysqli_fetch_array($run_pro_price)){
$product_price = array($row_price['product_price']);
$values = array_sum($product_price);
$total = $total + ($values * $prod_qty);
}
}
if($total >= 100){$delivery_rate = 0;}
//coupon code system starts - private
$get_couponQuery = "select * from coupon_code where customer_id = '$customer_id' ORDER BY coupon_id DESC LIMIT 1";
$run_couponQuery = mysqli_query($con, $get_couponQuery);
$count_couponQuery = mysqli_num_rows($run_couponQuery);
$row_couponQuery = mysqli_fetch_array($run_couponQuery);
if($count_couponQuery == 1){
$gt_couponID = $row_couponQuery["coupon_id"];
$gt_couponRatio = $row_couponQuery["deduction"];
$gt_couponUsage = $row_couponQuery["usage_status"];
$gt_couponCode = $row_couponQuery["coupon_code"];
$gt_couponExpiry = $row_couponQuery["date_of_expiry"];
$gt_couponStatus = $row_couponQuery["coupon_status"];
if($gt_couponUsage != "" && $gt_couponStatus == ""){
$deducVal = $total * $gt_couponRatio;
}else{
$deducVal = 0;
}
}
//coupon code system ends - private
if($count_couponQuery == 1){
$total = ($total - $deducVal) + $delivery_rate;
$total_in_usd = $total/$wiscoy_fx_rate;
}else{
$total = $total + $delivery_rate;
$total_in_usd = $total/$wiscoy_fx_rate;
}
?>
<?php
//$chkDateTime = date("Y-m-d h:m:s");
if($count_couponQuery == 1 && $gt_couponUsage == ""){
$presentDate = date("Y-m-d");
$preDay = strtotime($presentDate);
$expDay = strtotime($gt_couponExpiry);
if($preDay > $expDay){
}else{
echo "
<div class='row shadow'>
<br><div class='col-md-12'>
<form action='' method='POST'>
<div class='form-row'>
<div class='form-group col-md-8'>
<input type='text' class='input-control' id='custCouponCode' value='$gt_couponCode' readonly />
</div>
<div class='form-group col-md-4'>
<button type='submit' actualID='$gt_couponID' actualDeduction='$gt_couponRatio' id='submitCouponCode' class='btn btn-primary input-control'>Apply Coupon Code</button>
</div>
</div>
</form>
</div><br>
</div><hr />
";
}
}else{
}
?>
<script type="text/javascript">
$(document).ready(function(){
//Coupon Code Button Action
$("body").delegate("#submitCouponCode","click",function(e){
e.preventDefault();
var couponID = $(this).attr("actualID");
var actualDedctn = $(this).attr("actualDeduction");
$.ajax({
type:"POST",
url:"couponData.php",
data: { send_couponID: couponID, send_actualDedctn: actualDedctn },
success:function(new_entry){
swal({
title: new_entry,
text: "Thanks for Using The Watchtower!",
icon: "success",
button: "Click to Continue!",
});
setTimeout(function(){location.reload();}, 2000);
}
});
});
});
</script>
<?php //include("includes/paypal-stripe.php"); ?>
<div class="col-md-4"></div>
<div class="col-md-4"><!-- Cash on Delivery -->
<div class="">
<center>
<img src="images/pay-by-cash-on-delivery.jpg" class="img-responsive shadow" alt="WISPAZdotNET" />
</center><hr />
<center>
<a href="client_access/order.php?order=<?php echo $customer_id; ?>">
<button class="btn btn-block to-buy">Cash on Delivery</button>
</a>
</center>
<hr />
<p align="center" style="font-size: 20px;"><b>Amount Payable - <?php echo $currency; ?> <?php echo $total; ?></b></p>
<hr />
</div>
</div><!-- Cash on Delivery -->
<div class="col-md-4"></div>
<!--<p align="center">Please Allow This Page To Load Fully Before Proceeding With Payments. If You Prefer Other Payment Method or You Desire To Make A Direct Bank Transfer, Please Choose The <b>Cash on Delivery</b> Option, Thanks.</p>
<p align="center" style="font-size: 20px;"><b>Amount Payable - <?php echo $currency; ?> <?php echo $total; ?> | USD - <?php echo round($total_in_usd); ?></b></p>-->
<div class="clearfix"></div>
</div>
<br><br>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php } ?>