Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/marisgoldunisexboutique.com/public_html/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title>Saka Organic Foods - Order</title>
<?php
$ip_add = getenv("REMOTE_ADDR");
if(!isset($_SESSION["user_id"])){
echo "<meta http-equiv=\"refresh\" content=\"0; url=cart.php\">";
}
?>
<?php
if(isset($_POST['order'])) {
$address_id = $_POST['address'];
$check = mysqli_query($con,"SELECT * FROM shipping_addresses WHERE id='$address_id'");
if (mysqli_num_rows($check) > 0) {
while ($get = mysqli_fetch_array($check)) {
$city = $get["city"];
$state = $get["state"];
$address = $get["address"];
$shipping = $get["shipping"];
}//end of while loop
}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit;}
?>
<section class="bg-title-page p-t-40 p-b-50 flex-col-c-m" style="background-image: url(images/banner-min.jpg);">
<h2 class="l-text2 t-center">
<div class='space_top'></div>
Order confirmation
</h2>
</section>
<section class="bgwhite p-t-66 p-b-38">
<div class="container">
<div class="row">
<h2>Order Confirmation</h2><br/>
<?php
if (isset($_SESSION["user_id"])) {
echo'
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr><th><span class="cart_table">No.</span></th>
<th><span class="cart_table">Picture</span></th>
<th><span class="cart_table">Name</span></th>
<th><span class="cart_table">Unit Price NGN</span></th>
<th><span class="cart_table">Total Price NGN</span></th>
<th><span class="cart_table">Quantity</span></th>
</tr>
</thead>
<tbody>
';
//generate the order_id
$order_id = substr(md5(rand()), 0, 8);
$sql = "SELECT a.product_id,a.product_title,a.product_price,a.old_price,a.product_image,b.id,b.qty FROM products a,cart b WHERE a.product_id=b.p_id AND b.ip_add = '$ip_add'";
$run_query = mysqli_query($con,$sql);
$n=0;
while ($row=mysqli_fetch_array($run_query)) {
$n++;
$product_id = $row["product_id"];
$product_title = $row["product_title"];
$product_price = $row["product_price"];
$product_image = $row["product_image"];
$cart_item_id = $row["id"];
$qty = $row["qty"];
$old_price = $row["old_price"];
if(!$old_price == ""){
$full_price = $product_price;
$percent_off = $old_price;
$percentInDecimal = $percent_off / 100;
$percent = $percentInDecimal * $full_price;
$discounted_price = $full_price - $percent;
$product_price = $discounted_price;
}
echo '
<tr>
<span class="cart_table_go"><td>'.$n.'</span></td>
<td><span class="cart_table"><img class="img-responsive" src="product_images/'.$product_image.'"></span></td>
<td><span class="cart_table">'.$product_title.'</span></td>
<td><input style="border:none;font-weight:900;" type="text" class="form-control price" value="'.$product_price.'" readonly="readonly"></td>
<td><input style="border:none;font-weight:900;" type="text" class="form-control total" value="'.$product_price.'" readonly="readonly"></td>
<td><input style="border:none;font-weight:300;" type="text" class="form-control qty" value="'.$qty.'" readonly="readonly" ></td>
</tr>
';
//dump the cart details into this nifty looking array
$query = mysqli_query($con,"INSERT INTO cart_details VALUES(
'0',
'$order_id',
'$product_id',
'$product_title',
'$product_price',
'$product_image',
'$qty'
)")or die(mysqli_error($con));
//get total
$total = $qty * $product_price;
$total_array[] = $total;
}//while ends here
//get the total amount
$grand_total = array_sum($total_array);
$gt = $grand_total + $shipping;
echo"
</tbody>
</table>
</div>
<div class='row'>
<div class='col-md-12 col-xs-12 order_headings'>
<h4>Shipping to $address, $city, $state</h4>
</div>
</div>
";
echo '
<div class="col-md-12">
<b class="net_total" style="font-size:16px;"> </b><br/>
<b class="tot" style="font-size:16px;">Shipping: ₦'.$shipping.'</b><br/><br/>
<b class="tot" style="font-size:28px;color:cornflowerblue;">Grand Total: ₦';echo number_format("$gt"); echo'</b><br/>
<hr/>
</div>';
//for kobo thinz, paystack processes in kobo
function to_kobo($value)
{
return intval(
strval(floatval(
preg_replace("/[^0-9.]/", "", $value)
) * 100)
);
}
$amount_in_kobo = to_kobo("$gt");
?>
<div class='col-md-6 p-b-30'>
<p style='font-size:30px;'>PAY <span style='font-weight:700;'>ONLINE<span></p>
<p style='max-width:500px;text-align:justify;margin:auto;font-size:11px'>
Pay securely and conveniently using our secure online platform.
<br/>
</p><br/>
<form method="POST" action="order.php">
<script src="https://js.paystack.co/v1/inline.js"></script>
<div class="size15 trans-0-4">
<!-- Button -->
<button onclick="payWithPaystack()" type="button" class="flex-c-m sizefull bg1 bo-rad-23 hov1 s-text1 trans-0-4 redbackground" style="width:20%;">
Pay ₦<?php echo number_format("$gt"); ?>
</button>
</div>
</form>
<script>
function payWithPaystack(){
var handler = PaystackPop.setup({
key: 'pk_live_6d83c739b88bb2abc18236d6e43bfc83fb4110c7',
email: '<?php echo $email; ?>',
amount: <?php echo $amount_in_kobo; ?>,
callback: function(response){
//alert('success. transaction ref is ' + response.reference);
window.location = "verify_product.php?<?php echo "transaction_id=$order_id&type=Product&amount=$gt&";?>reference=" + response.reference;
},
onClose: function(){
//alert('window closed');
}
});
handler.openIframe();
}
</script>
</div>
<?php
}
?>
</div>
</div>
</section>
<!--grids-->
<?php include("footer.php");?>