aboutsummaryrefslogtreecommitdiff
path: root/lib/login.php
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-21 16:18:05 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-21 16:18:05 +0200
commit1bb67296c43b662cf00882971fcb3df655d7302b (patch)
treef52723fab0afd4131a42ecdbd782e7dbfe5dc29b /lib/login.php
parent569d61381723eea60188e00d6133fddcaee37ef8 (diff)
add/remove from cart working
Diffstat (limited to 'lib/login.php')
-rw-r--r--lib/login.php7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/login.php b/lib/login.php
index 0683031..05caf17 100644
--- a/lib/login.php
+++ b/lib/login.php
@@ -39,9 +39,10 @@ function check_login($username, $password) {
}
function get_cart_count() {
- global $username, $cursor;
- $statement = $cursor->prepare("select sum(cart.count) as count from cart join user on user.id = cart.user join product on product.id = cart.product where user.name = ?");
- $statement->bind_param("s", $username);
+ global $user_id, $cursor;
+ if (!$user_id) return 0;
+ $statement = $cursor->prepare("select ifnull(sum(count), 0) as count from webs.orderproduct where `order` = webs.cart(?)");
+ $statement->bind_param("i", $user_id);
if (!$statement->execute()) return 0;
$res = $statement->get_result();
if (!mysqli_num_rows($res)) return 0;