error_reporting(0); include_once "../Brain/field_const.php"; include_once "../Brain/functions.php"; include_once "../Brain/ShoppingCart.php"; include_once "../Brain/Product.php"; include_once "../Brain/UserControl.php"; if (!UserControl::checkState()) { echo "Error: You must login first!"; return; } regGet('act', 'prodNo', 'qty'); if (!isset($act) || !isset($prodNo)) { echo "Error: No action specified"; return; } $cart = new SCart(); $prod = getProduct($prodNo); //$cart->clear(); if ($act == 'add') { if (!isset($qty)) { $qty = 1; } $cart->addProduct($prodNo, $prod[prodPrice], $qty); //if not success //... } else { $cart->removeItem($prodNo); } $cartProds = $cart->getProducts(); //var_dump($cartProds); echo SCart::genCartMenuHtml($cartProds);
<?php include_once "Brain/ShoppingCart.php"; $cart = new SCart(); if (isset($_POST["removeID"])) { $cart->removeItem($_POST["removeID"]); echo "Removed"; return; } else { if (isset($_POST["getTotalAmount"])) { printf("%.02f", $cart->getTotalAmount()); return; } } echo "<html>"; include "header1.php"; ?> <script src="jquery_ui/external/jquery/jquery.js"></script> <link rel="stylesheet" type='text/css' href='jquery_ui/dataTable/jquery.dataTables.min.css'/> <script src="jquery_ui/dataTable/jquery.dataTables.min.js"></script> <link rel="stylesheet" href="jquery_ui/jquery-ui.min.css"> <link rel="stylesheet" href="css/shoppingCart.css"> <script src='js/shoppingCart.js'></script> <?php include "header2.php"; if (isset($_GET["sucess"])) { echo "<script> alert('Thank You!');</script>"; } ?> <body>