<th class="text-center">qty</th> <th class="text-center">price</th> <th class="text-center">subtotal</th> <th> </th> </tr> </thead> <tbody> <?php $subtotal = 0; $shipping_fee = 0; foreach ($cart_items as $each_cart_product) { $each_cart_item_id = $each_cart_product['product_id']; $each_cart_item_name = $productMgr->getProductName($each_cart_item_id); $each_cart_item_price = $productMgr->getPrice($each_cart_item_id); $each_cart_item_price_format = number_format($each_cart_item_price, 2, '.', ''); $each_cart_item_stock = $productMgr->getStock($each_cart_item_id); $each_cart_item_qty = $each_cart_product['quantity']; $each_cart_item_total = $each_cart_item_price * $each_cart_item_qty; $subtotal += $each_cart_item_total; $qtyid = $each_cart_item_id . 'qty'; $cboxid = $each_cart_item_id . 'cbox'; $removeBtnid = $each_cart_item_id . 'remove'; $each_cart_totalid = $each_cart_item_id . 'total'; ?> <tr> <td class="col-sm-1 col-md-1 text-center"> <div class="checkbox-cartItem"> <input id="<?php echo $cboxid; ?> " type="checkbox">
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ include_once "./Manager/ConnectionManager.php"; include_once "./Manager/ProductManager.php"; include_once "./Manager/PhotoManager.php"; $photoMgr = new PhotoManager(); $productMgr = new ProductManager(); $product_id = addslashes(filter_input(INPUT_POST, 'selected_product_id')); $color = addslashes(filter_input(INPUT_POST, 'color')); $qty = intval(addslashes(filter_input(INPUT_POST, 'qty'))); //$url = filter_input(INPUT_POST, 'url'); //print_r($url); $stock = $productMgr->getStock($product_id); session_start(); $userid = null; $addedQty = 0; $totalQty = 0; $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);
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ include_once "./Manager/ConnectionManager.php"; include_once "./Manager/ProductManager.php"; // define the filter type chosen before sort if any $changed_item_id = addslashes(filter_input(INPUT_POST, 'changed_item_id')); $qty_to_change = $_POST["qty_to_change"]; $customer_id = addslashes(filter_input(INPUT_POST, 'customer_id')); $color = addslashes(filter_input(INPUT_POST, 'color')); $productMgr = new ProductManager(); $stock = $productMgr->getStock($changed_item_id); $data_form = array(); if ($stock >= $qty_to_change) { $productMgr->updateItemQty($customer_id, $color, $changed_item_id, $qty_to_change); $stock = $productMgr->getStock($changed_item_id); $subtotal = 0; $shipping_fee = 0; $cart_items = $productMgr->retrieveFromShoppingCart($customer_id); foreach ($cart_items as $each_cart_product) { $each_cart_item_id = $each_cart_product['product_id']; $each_cart_item_name = $productMgr->getProductName($each_cart_item_id); $each_cart_item_price = $productMgr->getPrice($each_cart_item_id); $each_cart_item_qty = $each_cart_product['quantity']; $each_cart_item_total = $each_cart_item_price * $each_cart_item_qty; $subtotal += $each_cart_item_total; }