Exemplo n.º 1
0
function update_cart_to_db($cart = array('order' => null, 'order_details' => null))
{
    $order = get_order_in_session();
    $order_details = get_order_details_in_session();
    if (insert_order_to_db($order)) {
        $order_details = get_order_details_with_id($order_details);
        if (insert_order_details_to_db($order_details)) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Exemplo n.º 2
0
function delete_cart($productID)
{
    $cart = get_cart_in_session();
    $order = get_order_in_session();
    $order_details = get_order_details_in_session();
    foreach ($order_details as $key => $cart_item) {
        if ($cart_item['productID'] == $productID) {
            $order_details[$key] = null;
            $order_details = remove_array_null_or_empty_values($order_details);
            $order['total'] = get_total($order_details);
            $cart['order'] = $order;
            $cart['order_details'] = $order_details;
            $_SESSION[session_id()] = $cart;
            if ($_SESSION[session_id()]) {
                return $order['total'];
            } else {
                return false;
            }
        }
    }
}