<a class='overlay-text' href="./cart.php"><i class="fa fa-shopping-cart fa-lg"></i> Cart <span class="cart-qty"> ( <?php echo $cart_total_qty; ?> ) </span></a> <ul role="menu" class="sub-menu"> <?php if (!empty($cart_items)) { for ($x = 0; $x < min(4, count($cart_items)); $x++) { $each_cart_item = $cart_items[$x]; $each_product_id = $each_cart_item['product_id']; $each_product_color = $each_cart_item['color']; $cart_item_id = 'cartItem' . $each_product_id . $each_product_color; $each_product_quantity = $each_cart_item['quantity']; $each_product_name = $productMgr->getProductName($each_product_id); $photoList = $photoMgr->getPhotos($each_product_id); $photo_url = $photoList[$each_product_color]; ?> <li class="notification" data-itemid = '<?php echo $cart_item_id; ?> ' > <div class="cartImg"> <a href="./product_detail.php?selected_product_id=<?php echo $each_product_id; ?> &customer_id=<?php echo $userid; ?> &color=<?php echo $each_product_color;
$qty_update = false; $cart_data = array(); if (!empty($_SESSION["userid"])) { // $userid is customer email address $userid = $_SESSION["userid"]; $cart_data['error_not_logged_in'] = false; //add product to the shopping cart if ($productMgr->retrieveItemQtyInShoppingCart($userid, $product_id, $color) > 0) { $addedQty = $productMgr->retrieveItemQtyInShoppingCart($userid, $product_id, $color); $totalQty = $addedQty + $qty; $productMgr->updateItemQty($userid, $color, $product_id, $totalQty); $qty_update = true; } else { $productMgr->addProductToShoppingCart($userid, $product_id, $qty, $color); } $photoList = $photoMgr->getPhotos($product_id); $photo_url = $photoList[$color]; //get the number of item in customer's shopping cart $cart_qty = $productMgr->retrieveTotalNumberOfItemsInShoppingCart($userid); $cart_unique_qty = $productMgr->retrieveTotalNumberOfUniqueItemsInShoppingCart($userid); $item_qty = $productMgr->retrieveItemQtyInShoppingCart($userid, $product_id, $color); $product_name = $productMgr->getProductName($product_id); $cart_data['cart_qty'] = $cart_qty; $cart_data['cart_unique_qty'] = $cart_unique_qty; $cart_data['add_item_id'] = $product_id; $cart_data['item_qty'] = $item_qty; $cart_data['product_name'] = $product_name; $cart_data['photo_url'] = $photo_url; $cart_data['userid'] = $userid; $cart_data['qty_update'] = $qty_update; $cart_data['qty_to_change'] = $qty;
echo $cart_total_qty; ?> ) </span></a> <ul role="menu" class="sub-menu"> <?php if (!empty($cart_items)) { for ($x = 0; $x < min(4, count($cart_items)); $x++) { $each_cart_item = $cart_items[$x]; $each_product_id = $each_cart_item['product_id']; $each_product_color = $each_cart_item['color']; $cart_item_id = 'cartItem' . $each_product_id . $each_product_color; $item_quantity_id = $each_product_id . $each_product_color . 'cartQty'; $each_product_quantity = $each_cart_item['quantity']; $each_product_name = $productMgr->getProductName($each_product_id); $photoList = $photoMgr->getPhotos($each_product_id); $photo_url = $photoList[$each_product_color]; ?> <li class="notification" data-itemid = '<?php echo $cart_item_id; ?> ' > <div class="cartImg"> <a href="./product_detail.php?selected_product_id=<?php echo $each_product_id; ?> &customer_id=<?php echo $userid; ?> &color=<?php echo $each_product_color;
<th>Stock</th> <th width="10%">Edit</th> </tr> </thead> <tbody> <?php $photoMgr = new PhotoManager(); foreach ($product_list as $product) { $p_id = $product["product_id"]; $p_name = $product["product_name"]; $p_symbol_code = $product["symbol_code"]; $p_price = $product["price"]; $p_color = $product["color"]; $description = htmlentities($product["description"]); $p_stock = $product["stock"]; $photo_url_arr = $photoMgr->getPhotos($p_id); $photo_url_string = str_replace('"', """, str_replace(array("{", "}"), "", json_encode($photo_url_arr))); $p_color_optional_code_arr = $productMgr->getAllColorOptionalCodeByProduct($p_id); $p_color_optional_code_string = str_replace('"', """, str_replace(array("{", "}"), "", json_encode($p_color_optional_code_arr))); ?> <tr> <td><input type="checkbox" class="productList_id" value="<?php echo $p_id; ?> "></td> <td><?php echo $p_id; ?> </td> <td><?php echo $p_name;
if (!empty($_SESSION["userid"])) { // $userid is customer email address $userid = $_SESSION["userid"]; $pos = strpos($userid, "@"); // $username is displayed in the header $username = substr($userid, 0, $pos); } $checkoutList = $_POST; $productMgr = new ProductManager(); $photoMgr = new PhotoManager(); $list = []; //var_dump($checkoutList); foreach ($checkoutList as $checkout) { $product = $productMgr->getProduct($checkout["productId"]); $item = []; $photoList = $photoMgr->getPhotos($product["product_id"]); $item["product_id"] = $product["product_id"]; $item["product_name"] = $product["product_name"]; $item["color"] = $checkout["color"]; $item["thumbnail"] = $photoList[$item["color"]]; $item["quantity"] = $checkout["quantity"]; $item["price"] = $product["price"]; $item["subtotal"] = $checkout["quantity"] * $product["price"]; $item["add_to_cart_time"] = $checkout["create_time"]; array_push($list, $item); } include_once "./templates/header2.php"; $creditMgr = new CreditManager(); $creditList = $creditMgr->getUnusedCreditListByReceiverId($userid); ?>
$cart_total_qty = $productMgr->retrieveTotalNumberOfItemsInShoppingCart($userid); } $selected_product_id = addslashes(filter_input(INPUT_GET, 'selected_product_id')); $selected_product_color = addslashes(filter_input(INPUT_GET, 'color')); $product_selected = $productMgr->getProduct($selected_product_id); $selected_product_name = $product_selected['product_name']; $selected_product_description = $product_selected['description']; $selected_product_price = $product_selected['price']; $selected_product_stock = $product_selected['stock']; $selected_product_qty_id = $selected_product_id . 'qty'; $selected_qty_msg_id = $selected_product_id . 'msg'; $selected_add_btn_id = $selected_product_id . 'btn'; //if the customer is not logged in, the default quantity of product in the cart is 0 $selected_product_in_cart = 0; //if customer is logged in, check if the product is in the cart $selected_product_photoList = $photoMgr->getPhotos($selected_product_id); $selected_product_colorStr = $productMgr->getColor($selected_product_id); $selected_product_colorList = explode(",", $selected_product_colorStr); $color = !empty($selected_product_color) ? $selected_product_color : $selected_product_colorList[0]; if (!empty($userid)) { $selected_product_in_cart = $productMgr->retrieveItemQtyInShoppingCart($userid, $selected_product_id, $color); } ?> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="./public_html/css/bootstrap.min.css"> <link rel="stylesheet" href="./public_html/font-awesome-4.1.0/css/font-awesome.min.css"> <link rel="stylesheet" href="./public_html/css/main.css"> <link rel="stylesheet" href="./public_html/css/webShop.css"> <script src="./public_html/js/jquery-1.11.0.js"></script>