-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuycart.php
81 lines (74 loc) · 2.88 KB
/
buycart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php require 'config.php'; ?>
<?php require 'nav.php'; ?>
<?php
if(!isset($_SESSION['username']))
{
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
$url.= $_SERVER['HTTP_HOST'];
$url.= $_SERVER['REQUEST_URI'];
$_SESSION['back']=$url;
header('Location:'.'signin.php');
}
$uname=$_SESSION['username'];
$accountid=$_SESSION['accountid'];
$amount=0;
$sql="SELECT * from grocerycart where accountid=$accountid and status='Added to Cart';";
$result=$conn->query($sql);
while($row = $result->fetch_assoc())
{
$qty=$row['qty'];
$total=$row['total'];
$price=$row['price'];
$cart_id=$row['id'];
$pid=$row['productid'];
$sql="SELECT * from grocerycatalog where id=$pid;";
$res=$conn->query($sql);
$ro = $res->fetch_assoc();
$name=$ro["name"];
$amount+=$total;
$sql="update grocerycart set status='ordered' where id=$cart_id;";
$conn->query($sql);
$sql="insert into payments(payment_amount,qty,payment_status,itemid,page,orderfrom,custid,createdtime) values($total,$qty,'Completed',$cart_id,'grocery','cart',$accountid,'".date('Y-m-d H:i:s')."');";
$conn->query($sql);
$sql="insert into orders(custid,productid,qty,price,total,page,orderfrom,date) values($accountid,$cart_id,$qty,$price,$total,'grocery','cart','".date('Y-m-d H:i:s')."');";
$conn->query($sql);
}
$sql="SELECT * from customer where id=$accountid;";
$result=$conn->query($sql);
$row = $result->fetch_assoc();
//$email=$row["emailid"];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Paypal Integration Test</title>
</head>
<body>
<form class="paypal" action="payments.php" method="post" id="paypal_form" name="myform">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="UK" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="<?php echo $uname; ?>" />
<input type="hidden" name="last_name" value="" />
<input type="hidden" name="payer_email" value="<?php echo $email; ?>" />
<input type="hidden" name="item_name" value="<?php echo $name; ?>" />
<input type="hidden" name="item_number" value="<?php echo $pid; ?>" />
<input type="hidden" name="item_qty" value="<?php echo $qty; ?>" />
<input type="hidden" name="item_amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="custid" value="<?php echo $accountid; ?>" />
<input type="submit" hidden/>
</form>
<script>
window.onload = function(){
document.forms['myform'].submit();
}
</script>
</body>
</html>