$form_data['status'] = 'success'; $form_data['message'] = ""; //Add credit to the new signed-up account if there is credit sender information in session if (isset($_COOKIE["sender_email"])) { $sender_email = $_COOKIE["sender_email"]; $creditMgr->addCredit($sender_email, $email); $customerMgr->updateCredit($email, 10.0); $form_data['status'] = 'success'; $form_data['message'] = "Congratulations! You have got \$10 credits from your friend!"; setcookie('sender_email', '', time() - 1); } // Add cart item in temporary status into the cart of new signed-up account if (isset($_SESSION['temp_product_id_to_cart']) && !empty($_SESSION['temp_product_id_to_cart'])) { if ($productMgr->retrieveItemQtyInShoppingCart($userid, $_SESSION['temp_product_id_to_cart']) > 0) { $addedQty = $productMgr->retrieveItemQtyInShoppingCart($userid, $_SESSION['temp_product_id_to_cart']); $totalQty = $addedQty + $_SESSION['temp_product_qty_to_cart']; $productMgr->updateItemQty($userid, $_SESSION['temp_product_id_to_cart'], $totalQty); } else { $productMgr->addProductToShoppingCart($userid, $_SESSION['temp_product_id_to_cart'], $_SESSION['temp_product_qty_to_cart']); } unset($_SESSION['temp_product_id_to_cart']); unset($_SESSION['temp_product_qty_to_cart']); } if ($form_data['message'] != "") { header('location: index.php?status=' . $form_data['status'] . '&message=' . $form_data['message']); } else { header('location: index.php?'); } } else { header('location: test.php'); }
$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); $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;
* 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; } if ($subtotal > 100) { $shipping_fee = 0; } else {