</p>
	

	<?php 
    $cannot_get_package = false;
    if ($has_packages && $_REQUEST['pack'] != '') {
        // has packages, and a package was selected...
        // check to make sure this advertiser can order this package
        if (can_user_get_package($_SESSION['MDS_ID'], $_REQUEST['pack'])) {
            $sql = "SELECT quantity FROM temp_orders WHERE session_id='" . addslashes(session_id()) . "'";
            $result = mysql_query($sql) or die(mysql_error() . $sql);
            $row = mysql_fetch_array($result);
            $quantity = $row['quantity'];
            $block_count = $quantity / (BLK_WIDTH * BLK_HEIGHT);
            // Now update the order (overwite the total & days_expire with the package)
            $pack = get_package($_REQUEST['pack']);
            $total = $pack['price'] * $block_count;
            // convert & round off
            $total = convert_to_default_currency($pack['currency'], $total);
            $sql = "UPDATE temp_orders SET package_id='" . $_REQUEST['pack'] . "', price='" . $total . "',  days_expire='" . $pack['days_expire'] . "', currency='" . get_default_currency() . "' WHERE session_id='" . addslashes(session_id()) . "'";
            mysql_query($sql) or die(mysql_error() . $sql);
            $order_row['price'] = $total;
            $order_row['pack'] = $_REQUEST['pack'];
            $order_row['days_expire'] = $pack['days_expire'];
            $order_row['currency'] = get_default_currency();
        } else {
            $selected_pack = $_REQUEST['pack'];
            $_REQUEST['pack'] = '';
            $cannot_get_package = true;
        }
    }
Example #2
0
function add_package_to_order($order_id, $package_id)
{
    $pack = get_package($package_id);
    //user_id, order_id, blocks, status, order_date, price, quantity, banner_id, currency, days_expire, date_stam
    $sql = "SELECT * FROM orders WHERE order_id='{$order_id}'";
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result);
    $total = $row['quantity'] / 100 * $pack['price'];
    $total = convert_to_default_currency($pack['currency'], $total);
    $sql = "UPDATE orders set price='{$total}', currency='" . get_default_currency() . "' expire_days='" . $pack['expire_days'] . "' WHERE order_id={$order_id} ";
}