示例#1
0
 public function getCart()
 {
     $carts = array();
     $res = mysql_query("SELECT *,cart.id AS cid FROM cart INNER JOIN food ON cart.food_id=food.id WHERE user_id='" . $_SESSION['user'] . "'");
     if (mysql_num_rows($res) > 0) {
         while ($userRow = mysql_fetch_array($res)) {
             $cart = new Cart();
             $cart->setId($userRow['cid']);
             $cart->setFood($userRow['food']);
             $cart->setPrice($userRow['price']);
             $cart->setQuantity($userRow['quantity']);
             $cart->setFood_id($userRow['food_id']);
             $carts[] = $cart;
         }
     }
     return $carts;
 }
示例#2
0
 /**
  * this section is required 
  * to modify items
  */
 public function doModifyCart()
 {
     $basket = new Cart();
     $basket->getContents();
     $newQty = $_POST['newQty'];
     //preg_replace is required to clean up the url variable to numeric value
     $prodID = $_POST['pid'];
     $prodPrice = $_POST['price'];
     $basket->setQuantity($prodID, $newQty, $prodPrice);
     //sets the quantity of the item given the product id and quantity to change
 }
示例#3
0
    $foods = $processitem->getFoodFromIndex($_GET['home_search']);
} else {
    if (isset($_GET['search'])) {
        $foods = $processitem->getFoodFromFilters($_GET['search']);
    } else {
        if (isset($_GET['input-search'])) {
            $foods = $processitem->getFoodFromSearchBox($_GET['input-search']);
        } else {
            $foods = $processitem->getFood();
        }
    }
}
if (isset($_GET['cart'])) {
    $cart = new Cart();
    $cart->setFood_id($_GET['cart']);
    $cart->setQuantity('1');
    $processitem->addToCart($cart);
}
?>
						
	
	<section>
		<div class="container">
			<div class="row">
				<div class="col-sm-3">
					<div class="left-sidebar">
						<h2>Category</h2>
						<div class="panel-group category-products" id="accordian"><!--category-productsr-->
							<div class="panel panel-default">
								<div class="panel-heading">
									<h4 class="panel-title">
示例#4
0
文件: CartTest.php 项目: metator/cart
 function testShouldTotalPriceForAllItems()
 {
     $cart = new Cart();
     $cart->add(1, 10);
     $cart->add(2, 5);
     $cart->setQuantity(1, 10);
     // $100 worth of item 1
     $cart->setQuantity(2, 5);
     // $25 worth of item 2
     $this->assertEquals(125, $cart->totalPrice(), 'it totals price for all items');
 }
示例#5
0
 public function getQuantity($food_id)
 {
     $cart = new Cart();
     $res2 = mysql_query("SELECT * FROM cart WHERE food_id='" . $food_id . "' AND user_id='" . $_SESSION['user'] . "'");
     while ($userRow2 = mysql_fetch_array($res2)) {
         $cart->setQuantity($userRow2['quantity']);
     }
     return $cart;
 }
示例#6
0
    $review->setRday($rday);
    $review->setRtime($rtime);
    $msg = $processitems->addReview($review);
}
if (isset($_GET['id'])) {
    $food = new Foods();
    $food->setId($_GET['id']);
    $objs = $processitems->getProduct($food);
    $f = $objs[0];
    $s = $objs[1];
    $r = $objs[2];
} else {
    if (isset($_POST['id'])) {
        $c = new Cart();
        $c->setFood_id(mysql_real_escape_string($_POST['id']));
        $c->setQuantity(mysql_real_escape_string($_POST['quantity']));
        $processitems->addToCart($c);
    } else {
        header("Location: productList.php");
    }
}
?>

	
	<section>
		<div class="container">
			<?php 
if ($msg == 1) {
    ?>
							<div class="alert alert-success">
							  <strong>Oh Sanp!</strong> Error while updating data.