예제 #1
0
파일: functions.php 프로젝트: Misha099/lab6
function update_cart($cnt, $update_key, $in_cart)
{
    if ($cnt <= $in_cart && $cnt != 0) {
        $_SESSION['product_count'][$update_key] = $cnt;
        update_cart_sum();
    } elseif ($cnt == 0) {
        remove_from_cart($update_key);
    } else {
        $_SESSION['product_count'][$update_key] = $in_cart;
        update_cart_sum();
    }
}
예제 #2
0
<?php

session_start();
include $_SERVER['DOCUMENT_ROOT'] . '/cart.php';
remove_from_cart($_POST['product_id']);
?>
 
예제 #3
0
 */
if (isset($_GET["action"])) {
    $action = $_GET["action"];
    if ($action == "add") {
        if (isset($_GET["username"]) && isset($_GET["price"])) {
            $username = $_GET["username"];
            $price = $_GET["price"];
            add_to_cart($username, $price, $token);
            update_order_total();
        } else {
            echo json_encode(array("message" => "Error: missing username parameter."));
        }
    } else {
        if ($action == "remove") {
            if (isset($_GET["username"])) {
                remove_from_cart($_GET["username"]);
                update_order_total();
            } else {
                echo json_encode(array("message" => "Error: missing username parameter."));
            }
        } else {
            if ($action == "update") {
                if (isset($_GET["username"]) && isset($_GET["hours"])) {
                    $username = $_GET["username"];
                    $hours = $_GET["hours"];
                    update_user_total($username, $hours);
                    update_order_total();
                } else {
                    echo json_encode(array("message" => "Error: missing username parameter."));
                }
            } else {
예제 #4
0
 /**
  * Function to Update cart
  *
  * @return tempcode			The UI	
  */
 function update_cart()
 {
     $title = get_page_title('SHOPPING');
     $p_ids = post_param('product_ids');
     $pids = explode(",", $p_ids);
     $product_to_remove = array();
     $product_details = array();
     if (count($pids) > 0) {
         foreach ($pids as $pid) {
             $qty = post_param_integer('quantity_' . $pid);
             $object = find_product($pid);
             if (method_exists($object, 'get_available_quantity')) {
                 $available_qty = $object->get_available_quantity($pid);
                 if (!is_null($available_qty) && $available_qty <= $qty) {
                     $qty = $available_qty;
                     attach_message(do_lang_tempcode('PRODUCT_QUANTITY_CHANGED', strval($pid)), 'warn');
                 }
             }
             $product_details[] = array('product_id' => $pid, 'Quantity' => $qty);
             $remove = post_param_integer('remove_' . $pid, 0);
             if ($remove == 1) {
                 $product_to_remove[] = $pid;
             }
         }
     }
     update_cart($product_details);
     log_cart_actions('Updated cart');
     if (count($product_to_remove) > 0) {
         remove_from_cart($product_to_remove);
     }
     $cart_view = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $cart_view, do_lang_tempcode('CART_UPDATED'));
 }
예제 #5
0
<form name = "purchase" action="index.php?checkout=1&close=1" method="POST">
  <input type="text" hidden name="mail" value="1">
  <input class="complete_purchase_button" type="submit" value="complete purchase">
</form>
</div>
<div>
  <div class="continue_shopping_link"><a href="index.php?close=1">Continue Shopping!</a></div><!-- end .continue_shopping_link -->

</div>';
    // If the post variable "mail" is set and equals 1, send the confirmation email and display the confirmation message.
    if (isset($_POST['mail']) && $_POST['mail'] == 1) {
        $thanks = confirm_email($_SESSION['username']);
        if ($thanks) {
            echo $thanks;
        }
        if (!$thanks) {
            echo "There was a problem and we could not send your confirmation email";
        }
    }
    echo '</body></html>';
} elseif (isset($_GET['remove_cart']) && $_GET['remove_cart'] == 1) {
    remove_from_cart($_POST);
} elseif (!isset($_GET['admin']) && !isset($_GET['order'])) {
    $product_list = display();
    for ($i = 0; $i < count($product_list); $i++) {
        echo $product_list[$i];
    }
    echo "</div><!--end div.wrapper-->";
    echo '</body>
</html>';
}
예제 #6
0
파일: cart.php 프로젝트: Misha099/lab6
<?php

session_start();
include 'connection.php';
include 'functions.php';
if (empty($_SESSION['prod_count'])) {
    $_SESSION['prod_count'] = 0;
}
if (isset($_POST['add_to_cart_button'])) {
    addtocart($_POST['product_id'], $_POST['price']);
}
if (isset($_POST['update'])) {
    update_cart($_POST['p_count'], $_POST['upd_id'], $_POST['in_cart']);
}
if (isset($_POST['delete'])) {
    remove_from_cart($_POST['del_id']);
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Test shop</title>

<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="header">
예제 #7
0
<?php

include '../db-connections/db-connection.php';
include 'projects.php';
header('Content-Type: application/json');
echo json_encode(remove_from_cart($_POST['id']));