示例#1
0
文件: cart.php 项目: anton-kol/buelo
function getAgentOrder($userID)
{
    $managerID = getManagerID($userID);
    $query = mysql_query("SELECT COUNT(id) FROM agent_orders WHERE manager_id = '" . $managerID . "' AND !status");
    $res = mysql_fetch_array($query);
    if ($res == 0) {
        return null;
    }
    $query = mysql_query("SELECT agent_orders.*, customers.name AS customer FROM agent_orders LEFT JOIN customers ON customers.id = agent_orders.customer_id WHERE agent_orders.manager_id = '" . $managerID . "' AND !agent_orders.status");
    $order = mysql_fetch_array($query);
    return (object) $order;
}
示例#2
0
文件: order.php 项目: anton-kol/buelo
function addToCart()
{
    global $user;
    $managerID = getManagerID($user['id']);
    $order = getAgentOrder($user['id']);
    $query = mysql_query("SELECT COUNT(id) FROM agent_cart WHERE order_id = '" . $order->id . "' AND product_id = '" . $_POST['id'] . "' ");
    $res = mysql_fetch_array($query);
    if ($res[0] > 0) {
        mysql_query("UPDATE agent_cart SET quantity = '" . $_POST['q'] . "' WHERE order_id = '" . $order->id . "' AND quantity = '" . $_POST['id'] . "' ");
    } else {
        mysql_query("INSERT INTO agent_cart (order_id, product_id, quantity) VALUES ('" . $order->id . "', '" . $_POST['id'] . "', '" . $_POST['q'] . "' ) ");
    }
    $incart = getAgentCartCount();
    echo $incart;
}