예제 #1
0
    $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;
    $cart_data['product_color'] = $color;
} else {
    $cart_data['error_not_logged_in'] = true;
    $_SESSION['temp_product_id_to_cart'] = $product_id;