当前位置: 首页>>代码示例>>PHP>>正文


PHP addToCart函数代码示例

本文整理汇总了PHP中addToCart函数的典型用法代码示例。如果您正苦于以下问题:PHP addToCart函数的具体用法?PHP addToCart怎么用?PHP addToCart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addToCart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addToCart

if (isset($_POST['Movie'])) {
    $_SESSION['movie'] = $_POST['Movie'];
}
if (isset($_POST['Day'])) {
    $_SESSION['day'] = $_POST['Day'];
}
if (isset($_POST['Time'])) {
    $_SESSION['time'] = $_POST['Time'];
}
if (isset($_POST['Seat'])) {
    $_SESSION['seat'] = $_POST['Seat'];
}
if (isset($_POST['order'])) {
    if (isset($_POST['product_id'])) {
        $product_id = $_POST['product_id'];
        addToCart($product_id);
    }
}
?>

        <nav>
            <ul>
                <li><a href="index.php">Home</a></li>
                <li><a href="movies.php">Movies</a></li>
                <li><a class="active" href="booking.php">Booking</a></li>
                <li><a href="contact-us.php">Contact Us</a></li>
            </ul>
        </nav>

        <div class="content-full-height">
            <div class="container-main">
开发者ID:s3483592,项目名称:Assignment-2,代码行数:31,代码来源:booking-content.php

示例2: addToShopCart

<script>
function addToShopCart(itemID)
{
	alert(itemID);
	//alert("<?php 
addToCart(itemID);
?>
");
}
</script>

<?php 
session_start();
function connectToDB()
{
    $ini_array = parse_ini_file("credentials.ini");
    $serverName = $ini_array["servername"];
    $userName = $ini_array["username"];
    $password = $ini_array["password"];
    //echo $password;
    $con = mysqli_connect($serverName, $userName, $password, 'project');
    if (!$con) {
        die("Cannot connect: " . mysqli_connect_error());
    } else {
        //echo "Connection successful.\n\n";
    }
    return $con;
}
function closeDB($con)
{
    mysqli_close($con);
开发者ID:gavmac11,项目名称:Practice-PHP-and-mySQL,代码行数:31,代码来源:functions.php

示例3: strip_tags

<?php

require_once 'functions.php';
$action = strip_tags($_GET["action"]);
switch ($action) {
    case "changeQuantity":
        changeQuantity($_GET['id'], $_GET['val'], $_GET['price']);
        break;
    case "addToCart":
        addToCart($_GET['id'], $_GET['price']);
        break;
    case "getCart":
        getCart();
        break;
    case "del":
        delProduct($_GET['id']);
        break;
    case "complite":
        complite();
        break;
}
开发者ID:anderpo,项目名称:7hours.loc,代码行数:21,代码来源:controller.php

示例4: Database

<?php

require_once "../includes/LIB-project1.php";
require_once "../includes/Paginator.class.php";
require_once "../includes/Database.class.php";
//open connection
$dbObj = new Database();
//if set, add to cart and unset variable for future use
if (isset($_GET['addToCart'])) {
    addToCart($dbObj, $_GET['addToCart']);
    unset($_GET['addToCart']);
    //unset it so it'll pick up future ones
}
//null = css files
$css = array("main.css", "bootstrap.min.css");
$curr_page = "Home";
//even though the page is Admin, still considered "Account"
//git divs for sales / category
$pageHTML = getSalesCatalog($dbObj, $curr_page);
//include the template
include "../includes/HTML_template.php";
//close everything
$dbObj->closeDbh();
开发者ID:jrg4017,项目名称:E-CommerenceSite-PHP-Practice,代码行数:23,代码来源:index.php

示例5: Item

    $iid = $_POST['item_id'];
    $item = new Item();
    $item->populatItem($iid);
    $qtty = abs($_POST['qtty']);
    $size = $_POST['price_group'];
    switch ($size) {
        case 'S':
            $price = $item->prices;
            break;
        case 'M':
            $price = $item->pricem;
            break;
        case 'L':
            $price = $item->pricel;
    }
    addToCart($iid, $item->itemname, $qtty, $price, $item->itemCode, $remarks);
    $notice = sprintf(__('Added %s to the cart (Quantity: %s)'), $item->itemname, $qtty);
}
get_top_nav();
//Call the navigation
?>


<div id="wrap">
	<div id="widecb" >
	<div id="additemnav">
			<ul>
				<li><a href="<?php 
echo HOME . 'menu/6';
?>
" title=""><?php 
开发者ID:nitzanb,项目名称:letseat,代码行数:31,代码来源:menu.php

示例6: session_start

<?php

/**
 * Created by PhpStorm.
 * User: master
 * Date: 2016/7/13
 * Time: 20:47
 */
session_start();
$project = $_SESSION['project'];
$option = $_POST['option'];
$items = $_POST['items'];
//$items = json_decode($items,true);
if ($option == 'add') {
    addToCart($items, $project);
    echo "success";
} else {
    if ($option == 'remove') {
        removeFromCart($items, $project);
        //print_r($_SESSION[$project]['idList']);
        echo "success";
    } else {
        if ($option == 'show') {
            echo json_encode($_SESSION[$project]['idList']);
        } else {
            if ($option = 'removeAll') {
                removeAll($project);
                echo "success";
            }
        }
    }
开发者ID:buaacotest,项目名称:cotest,代码行数:31,代码来源:compareCart.php

示例7: session_start

<?php

session_start();
require_once '../includes/helper.php';
require_once '../includes/codemojo.php';
$gamificationService->addAchievements(getUserID(), 'reader');
addToCart($_POST['title'], $_POST['price']);
response(array("code" => 200));
开发者ID:codemojo-dr,项目名称:startkit-php-sample,代码行数:8,代码来源:addToCart.php

示例8: startCart

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
require_once '../includes/session-start.req-inc.php';
require_once '../functions/cart-functions.php';
require_once '../functions/dbConn.php';
require_once '../functions/until.php';
require_once '../functions/category-functions.php';
require_once '../functions/products-functions.php';
startCart();
$allCategories = getAllCategories();
$allProducts = getAllProducts();
$categorySelected = filter_input(INPUT_GET, 'cat');
$action = filter_input(INPUT_POST, 'action');
if ($action === 'buy') {
    $productID = filter_input(INPUT_POST, 'product_id');
    addToCart($productID);
}
include_once '../includes/categories.html.php';
include_once '../includes/products.html.php';
?>
    </body>
</html>
开发者ID:slasher15987,项目名称:PHPSummerClass2015,代码行数:28,代码来源:index.php

示例9: getContent

/**
 * Функция которая возвращает массив информации
 * о просматриваемой страничка с типом $type
 * и $id
 * @param null $type
 * @param null $id
 * @return array
 */
function getContent($type = null, $id = null)
{
    /*Если параметры null, то выводим страничку по умолчанию*/
    if ($type == null) {
        $type = DEFAULT_PAGE;
    }
    if (isset($_POST['new_submit']) && $_POST['new_submit']) {
        $type = NEW_SUBMIT_TYPE;
    }
    $loginStatus = LOGIN_ALREADY;
    if (isset($_GET['unlogin']) && $_GET['unlogin']) {
        unlogin();
        $loginStatus = LOGIN_EXIT;
    }
    if ($_POST['submit']) {
        $loginStatus = login($_POST['login'], $_POST['password']);
    }
    /*Инициализируем информацию в зависимости от типа */
    $array = array();
    switch ($type) {
        /*Если тип страницы - текстовая*/
        case TEXT_TYPE:
            /*Если id не инициализирован выводим главную.
            		Иначе страницу с id*/
            if ($id == null) {
                $id = MAIN_PAGE_TEXT_ID;
            }
            /*Получаем текст из базы*/
            $page = getTextContent($id);
            $array['content'] = $page['text'];
            break;
        case CATALOG_TYPE:
            /*Если id не инициаизирован */
            if (!($id > 0)) {
                /*Выбираем первый попавшийся театр*/
                $sql = "SELECT id from theatures LIMIT 1";
                $res = mysql_query($sql);
                $row = mysql_fetch_array($res);
                $id = $row['id'];
            }
            /*Получаем спектали из базы*/
            $items = getCatalogItems($id);
            //$parent_item = get;
            /*Вставляем их в ш для красивого вывода*/
            $array['content'] = (include 'templates/content/item/items.php');
            break;
        case ITEM_TYPE:
            $item = getItem($id);
            $array['content'] = (include 'templates/content/item/item_big.php');
            break;
        case NEW_REG_TYPE:
            $array['content'] = (include 'templates/content/login/newreg.php');
            break;
        case NEW_SUBMIT_TYPE:
            //Если пароли совпадают
            if ($_POST['new_password1'] == $_POST['new_password2']) {
                if (addNewUser($_POST['new_login'], $_POST['new_password2'])) {
                    $array['content'] = 'Поздравляем вы зарегистерированы';
                } else {
                    $array['content'] = 'Такой пользователь уже есть';
                }
            } else {
                $array['content'] = 'Пароли не совпадают';
            }
            break;
        case ADD_CART_TYPE:
            addToCart($id);
            $cartItems = getCartItems();
            $sum = calculateCart();
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
        case CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
            /*Удаляем одну штуку*/
        /*Удаляем одну штуку*/
        case REMOVE_CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            removeFromCart($id);
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
            /*Удаляем весь товар*/
        /*Удаляем весь товар*/
        case REMOVE_ITEM_CART_TYPE:
            $cartItems = getCartItems();
            $sum = calculateCart();
            removeFromCart($id, CART_REMOVE_ALL);
            $array['content'] = (include 'templates/content/cart/cart.php');
            break;
//.........这里部分代码省略.........
开发者ID:Angelinkka,项目名称:curs,代码行数:101,代码来源:functions.php

示例10: loginTime

        echo $category['name'];
        ?>
</a>
                    </li>

                <?php 
    }
    ?>
            </ul>
        </div>

        <?php 
    if (isset($_POST['cart'])) {
        loginTime();
        $qty = $_POST['qty'];
        addToCart($_SESSION['customerId'], $product->entity_id, $qty);
    }
    ?>
        <?php 
    if ($product) {
    }
    ?>

        <span><?php 
    echo $product->name;
    ?>
</span>
        <span><?php 
    echo $product->price;
    ?>
</span>
开发者ID:Substractive,项目名称:student-web-shop,代码行数:31,代码来源:product_page.php

示例11: foreach

include "cart.php";
if (isset($_SESSION['cart'])) {
    $cartSum = 0;
    $cartCount = 0;
    foreach ($_SESSION['cart'] as $itemId => $count) {
        $itemSql = getItem($itemId)[0];
        $cartSum += $itemSql['price'] * $count;
        $cartCount += $count;
    }
} else {
    $cartSum = 0;
    $cartCount = 0;
}
switch ($type) {
    case 4:
        addToCart($id);
        break;
    case 5:
        freeCart();
        header("location: http://" . $_SERVER['HTTP_HOST']);
        break;
    case 6:
        include "cart_out_mail.php";
        include "sendmail.php";
        sendMail('vera_potapova_95@mail.ru', $cartOut, 'Информация по заказку');
        freeCart();
        freeCart();
        break;
    case 7:
        deleteOneFromCart($id);
        header("location: http://" . $_SERVER['HTTP_HOST'] . "?type=4");
开发者ID:verapotapova,项目名称:WebShop,代码行数:31,代码来源:autorun.php

示例12: oci_bind_by_name

             oci_bind_by_name($s, ':pid_prefix', $plook);
             oci_execute($s);
             //fetch a single row depending on product id
             $res = oci_fetch_assoc($s);
             echo "Product name: ", $res['PRODUCTNAME'], " Price: ", $res['PRODUCTPRICE'];
             echo '<a href="cart.php?del=' . $i . '"> Remove item</a><br>';
         }
     }
     if ($cartLen > 0) {
         echo '<a href="checkout.php">Proceed to checkout</a><br>';
     }
 }
 //if item has been added
 if (isset($_GET['add'])) {
     $pID = $_GET['add'];
     addToCart($pID);
     dispCart();
 }
 //if item has been deleted
 if (isset($_GET['del'])) {
     $val = $_GET['del'];
     unset($_SESSION['cart'][$val]);
     //keep array indexes intact
     $_SESSION['cart'] = array_values($_SESSION['cart']);
 }
 if (!isset($_GET['add'])) {
     dispCart();
 }
 //
 echo '<a href="main.php">Keep shopping</a><br>';
 //echo "<br>$cartLen";
开发者ID:Emadbox,项目名称:eStore,代码行数:31,代码来源:cart.php

示例13: header

<?php

include 'modules.php';
if (!isset($_COOKIE['uid'])) {
    header('Location: index');
}
$pid = $_GET["pid"];
$type = findType($pid);
$uid = $_COOKIE['uid'];
if (isset($_POST['addToWishButton'])) {
    //echo $_COOKIE['uid'];
    addToWish($pid, $uid);
    //exit();
} else {
    if (isset($_POST['addToCartButton'])) {
        addToCart($pid, $uid, $_POST['quantity'], $_POST['filter']);
        //exit();
    }
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="ISO-8859-1">
	<title>Product Page</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet"
	href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
	<script
	src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script
开发者ID:harshatjk,项目名称:ERA81,代码行数:31,代码来源:product.php

示例14: addToCart

function addToCart($item_id)
{
    global $test;
    $user = getUserIdByUserName($_SESSION['user']);
    $query = "INSERT into shopping_cart(quantity, item_id, user_id) VALUES(1," . $item_id . "," . $user['user_id'] . ")";
    $statement = $test->prepare($query);
    $statement->execute();
    if ($statement->rowCount()) {
        $_SESSION['cart_msg'] = "item was successfully added";
    } else {
        $_SESSION['cart_msg'] = "Item wasn't added. See your database administrator";
    }
    $statement->closeCursor();
}
function getUserIdByUserName($username)
{
    global $test;
    $query = "SELECT user_id FROM user_name WHERE user_name ='{$username}'";
    $statement = $test->prepare($query);
    $statement->execute();
    $user = $statement->fetch();
    $statement->closeCursor();
    return $user;
}
/*above are shopping-cart functions */
if ($doubles == TRUE) {
    $_SESSION['cart_msg'] = "this item is already in your wish list cart";
} else {
    addToCart($_GET['item']);
}
header("Location: whybuy.php");
开发者ID:Olney-James,项目名称:cs313-php,代码行数:31,代码来源:addToCart.php

示例15: mysql_connect

<?php 
$mini1 = mysql_connect("localhost", "blognadine", "111111") or die(mysql_error());
mysql_select_db("mini1", $mini1);
$sql = "SELECT * FROM items";
$items = mysql_query($sql, $mini1);
//$_SESSION['cart'] = array('name' => array(),'price' => array(),'itemID' => array(),'stock' => array());
while ($row = mysql_fetch_array($items)) {
    echo "<br>" . "<br>";
    addToCart($row['name'], $row['price'], $row['itemID'], $row['stock']);
}
$count = 0;
foreach ($_SESSION['cart'] as $attribute => $values) {
    echo '<h1>' . $attribute . '</h1>';
    echo '<ul>';
    foreach ($values as $shit) {
        echo '<li>' . $shit . '</li>';
    }
    echo '</ul>';
}
?>


<?php 
function addToCart($name, $price, $itemID, $stock)
{
    if (isset($_SESSION['cart'])) {
        array_push($_SESSION['cart']['name'], $name);
        array_push($_SESSION['cart']['price'], $price);
        array_push($_SESSION['cart']['itemID'], $itemID);
        array_push($_SESSION['cart']['stock'], $stock);
开发者ID:NadineMansour,项目名称:ecommerce2,代码行数:30,代码来源:items.php


注:本文中的addToCart函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。