function deleteAdminProducts()
{
    $scm = new ShoppingCartManager();
    if ($_POST['delete'] == "delete") {
        $response = $scm->deleteAdminProducts();
        echo json_encode($response);
    }
}
Beispiel #2
0
<?php

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
require 'scripts/init.php';
loadScripts();
$dishId = $_POST["dishId"];
$scm = new ShoppingCartManager();
//$scm->getCartId();
$item = array("dishId" => $dishId, "qty" => "1");
$scm->addItemsToCart($item);
echo json_encode($scm->ToJSON(), JSON_FORCE_OBJECT);
<?php

require_once './init.php';
loadScripts();
$data = array("status" => "not set!");
if (Utils::isPOST()) {
    $scm = new ShoppingCartManager();
    $parameters = new Parameters("POST");
    $action = $parameters->getValue('action');
    if (session_status() == PHP_SESSION_NONE) {
        session_start();
    }
    switch ($action) {
        case "startcart":
            // start the cart, so start session, create cart table in DB
            if (isset($_SESSION['started'])) {
                $data = array("status" => "fail", "msg" => "You already have a cart started.");
                echo json_encode($data, JSON_FORCE_OBJECT);
                return;
            }
            $id = $scm->startCart();
            if (!empty($id)) {
                $_SESSION['started'] = "true";
                $_SESSION['id'] = $id;
                $data = array("status" => "success", "cart_id" => $id, "msg" => "Cart started.");
            } else {
                $data = array("status" => "fail", "msg" => "Cart NOT started.");
            }
            break;
        case "cancelcart":
            // cancel the cart, end session, set cart row to 'cancelled'
<?php

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
require 'scripts/init.php';
loadScripts();
$scm = new ShoppingCartManager();
$k = $scm->checkoutCart();
//$scm->setCartId();
$username = $scm->getShoppingCartOwner();
if ($k > 0) {
    $data = array('msg' => 'Cart checked out', 'cartOwner' => $username);
} else {
    $data = array('msg' => 'Cart has not been updated');
}
//unset($_SESSION['cartId']);
echo json_encode($data, JSON_FORCE_OBJECT);
<?php

require_once '../libs/PHPTAL-1.3.0/PHPTAL.php';
require_once '../init.php';
loadScripts();
$data = array("status" => "not set!");
if (Utils::isPOST()) {
    $scm = new ShoppingCartManager();
    $parameters = new Parameters("POST");
    $action = $parameters->getValue('action');
    if (session_status() == PHP_SESSION_NONE) {
        session_start();
    }
    switch ($action) {
        case "startcart":
            // start the cart, so start session, create cart table in DB
            if (isset($_SESSION['started'])) {
                $data = array("status" => "fail", "msg" => "You already have a cart started.");
                echo json_encode($data, JSON_FORCE_OBJECT);
                return;
            }
            $id = $scm->startCart();
            if (!empty($id)) {
                $_SESSION['started'] = "true";
                $_SESSION['cart_id'] = $id;
                $_SESSION['isCustomer'] = "true";
                //Session::set("isCustomer", true);
                $data = array("status" => "success", "cart_id" => $id, "msg" => "Cart started.", "session" => $_SESSION['isCustomer']);
            } else {
                $data = array("status" => "fail", "msg" => "Cart NOT started.");
            }
<?php

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
require 'scripts/init.php';
loadScripts();
$scm = new ShoppingCartManager();
$scm->getOpenCart();
$data = $scm->ToJSON();
echo json_encode($data, JSON_FORCE_OBJECT);