-
Notifications
You must be signed in to change notification settings - Fork 1
/
reduce_checkout.php
115 lines (73 loc) · 3.19 KB
/
reduce_checkout.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
session_start();
if(isset($_SESSION['u_name'])){
$us_name= $_SESSION['u_name'] ;
require_once "connect.php";
//REDUCE CART QUANTITY TO NULL, 29-03-2018, Prabhat Chandra
$sql = $conn->query("SELECT u_cart.p_id, u_cart.user_name, u_cart.u_qty,
i_new_product.id, i_new_product.price,
u_cart.u_qty - u_cart.u_qty AS ext_price
FROM i_new_product
LEFT JOIN u_cart ON i_new_product.id = u_cart.p_id")
or die(mysqli_error($conn)) ;
while($min = $sql->fetch_array()){
//$id = $min['id'];
$t_price = $min['ext_price'];
$conn->query("UPDATE `u_cart` SET `u_price` = '$t_price'
WHERE user_name='$us_name' ")
or die(mysqli_error($conn));
}
//Cart Price Calculation, Here to NULL, Created on 30-03-2018, Prabhat Chandra
$sql = $conn->query("SELECT p_id, user_name, SUM(u_price) AS t_price
FROM u_cart
GROUP BY user_name = '$us_name'
;")
or die(mysqli_error($conn)) ;
while($min = $sql->fetch_array()){
$id = $min['p_id'];
$cus_name = $min['user_name'];
$totalprice = $min['t_price'];
$conn->query("REPLACE INTO `cart_t` VALUES( '$cus_name', '$totalprice' )") or die(mysqli_error($conn));
}
//REDUCE CART QUANTITY TO NULL, 29-03-2018, Prabhat Chandra
$sql = $conn->query("SELECT u_cart.p_id, u_cart.user_name, u_cart.u_qty,
i_new_product.id, i_new_product.price,
u_cart.u_qty - u_cart.u_qty AS ext_qty
FROM i_new_product
LEFT JOIN u_cart ON i_new_product.id = u_cart.p_id")
or die(mysqli_error($conn)) ;
while($min = $sql->fetch_array()){
//$id = $min['id'];
$ext_qty = $min['ext_qty'];
$conn->query("UPDATE `u_cart` SET `u_qty` = '$ext_qty'
WHERE user_name='$us_name' ")
or die(mysqli_error($conn));
}
//Cart QUANTITY Calculation, Created on 30-03-2018, Prabhat Chandra
$sql = $conn->query("SELECT user_name, SUM(u_qty) AS tt_qty
FROM u_cart
GROUP BY user_name = '$us_name'
;")
or die(mysqli_error($conn)) ;
while($tq = $sql->fetch_array()){
$totalqty = $tq['tt_qty'];
//echo $totalqty;
$conn->query("REPLACE INTO `cart_t_q` VALUES( '$us_name', '$totalqty' )") or die(mysqli_error($conn));
}
//REMOVE ITEM FROM CART, 30-03-2018, Prabhat Chandra
$conn->query("DELETE FROM u_cart
WHERE user_name='$us_name' ")
or die(mysqli_error($conn));
// END OF QUERY, aPCreations
//Redirection while checking query error, 10-04-2018, Prabhat Chandra
if (!$sql) {
header('Location: error.php', TRUE, 303);
die('Invalid query: ' . mysql_error());
} else {
header('Location: paydone.php', TRUE, 303);
die('Success');
}
} else {
header('Location: error.php');
}
?>