Commit 3e86014d authored by Maneesha Fernando's avatar Maneesha Fernando Committed by GitHub

Delete update-cart.php

parent 9930ea52
<?php
//if (session_status() !== PHP_SESSION_ACTIVE) {session_start();}
if(session_id() == '' || !isset($_SESSION)){session_start();}
include 'config.php';
$product_id = $_GET['id'];
$action = $_GET['action'];
if($action === 'empty')
unset($_SESSION['cart']);
$result = $mysqli->query("SELECT qty FROM products WHERE id = ".$product_id);
if($result){
if($obj = $result->fetch_object()) {
switch($action) {
case "add":
if($_SESSION['cart'][$product_id]+1 <= $obj->qty)
$_SESSION['cart'][$product_id]++;
break;
case "remove":
$_SESSION['cart'][$product_id]--;
if($_SESSION['cart'][$product_id] == 0)
unset($_SESSION['cart'][$product_id]);
break;
}
}
}
header("location:cart.php");
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment