Warning: session_start(): open(/var/lib/php5/sessions/sess_rse96au9fcefc51uu0joh2vn91, O_RDWR) failed: Permission denied (13) in /var/extra/public_html/includes/common.php on line 21 Call Center Product Downloads fix
Our site www.viart.com site is operated by latest Viart Shop 5 with default Clear design
Topic Information
Gustaf
Gustaf
prod_download_fix.txt (4Kb)  
I fixed the product download issue with the call center. There were two bugs:
 
-- The statuses weren't updated the same way statuses are updated for normal user orders (those who use the call center may have noticed that call center orders have one status change whereas user orders have three)
 
-- Download information was being taken from the items table which is no longer the correct place to get it
 
The following is a fix for both issues:
(indentation has been removed so I also attached a txt file which maintains indentation)
 
-------------------
In admin_order_call.php
-------------------
-- On line 1428 change 'false' to 'true'
 
-- After line 1431 add the following four lines:
update_order_status($r->get_value("order_id"), 2, true, "", $status_error);
if ($status_error) {
$r->errors .= $status_error . "'<br>";
}
 
 
-- Replace the function after_orders_items_save with the following:
 
function after_orders_items_save($order_id, $user_id, $order_item_id, $item_id)
{
global $table_prefix, $db_type, $db, $eg;
 
$quantity = $eg->record->get_value("quantity");
$generation_type = 0;
$downloadable = 0;
$downloads = array();
 
// Get serial information
$sql = 'SELECT generate_serial FROM '.$table_prefix.'items WHERE item_id='.$db->tosql($item_id, INTEGER);
$db->query($sql);
if ($db->next_record()){
$generation_type = $db->f('generate_serial');
}
 
$product_info = array("item_id" => $item_id);
// Generate serial numbers
if ($generation_type > 0) {
for ($sn = $quantity; $sn > 0; $sn--) {
$serial_number = generate_serial($order_item_id, $sn, $product_info, $generation_type);
if ($serial_number) {
$sql = " INSERT INTO " . $table_prefix ."orders_items_serials (order_id, user_id, order_item_id, item_id, serial_number, serial_added) ";
$sql .= " VALUES (" . $db->tosql($order_id, INTEGER) . ", ";
$sql .= $db->tosql($user_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($order_item_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($item_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($serial_number, TEXT) . ",";
$sql .= $db->tosql(va_time(), DATETIME) . ")";
$db->query($sql);
}
}
}
 
// Get download information
$sql = 'SELECT * FROM ' . $table_prefix .'items_files WHERE item_id=' . $db->tosql($item_id, INTEGER);
$db->query($sql);
while ($db->next_record()) {
$downloadable = 1;
$temp = array();
$temp['download_interval'] = $db->f('download_interval');
$temp['download_path'] = $db->f("download_path");
$temp['max_downloads'] = $db->f("download_limit");
$temp['download_period'] = $db->f("download_period");
$downloads[] = $temp;
}
 
// Insert download records into database
if ($downloadable) {
$current_date = va_time();
foreach ($downloads as $dl) {
$sql = " INSERT INTO " . $table_prefix ."items_downloads (order_id, user_id, order_item_id, item_id, ";
$sql .= "download_path, max_downloads,download_limit, download_added,download_expiry) ";
$sql .= " VALUES (" . $db->tosql($order_id, INTEGER) . ", ";
$sql .= $db->tosql($user_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($order_item_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($item_id, INTEGER, true, false) . ",";
$sql .= $db->tosql($dl['download_path'], TEXT) . ",";
$sql .= $db->tosql($dl['max_downloads'] * $quantity, INTEGER) . ",";
$sql .= $db->tosql($dl['max_downloads'] * $quantity, INTEGER) . ",";
$sql .= $db->tosql(va_time(), DATETIME) . ",";
$download_period = $dl['download_period'];
if ($download_period == 1) {
$download_expiry = mktime (0, 0, 0, $current_date[MONTH], $current_date[DAY] + $download_interval, $current_date[YEAR]);
} elseif ($download_period == 2) {
$download_expiry = mktime (0, 0, 0, $current_date[MONTH], $current_date[DAY] + ($download_interval * 7), $current_date[YEAR]);
} elseif ($download_period == 3) {
$download_expiry = mktime (0, 0, 0, $current_date[MONTH] + $download_interval, $current_date[DAY], $current_date[YEAR]);
} else {
$download_expiry = mktime (0, 0, 0, $current_date[MONTH], $current_date[DAY], $current_date[YEAR] + $download_interval);
}
$sql .= $db->tosql($download_expiry, DATETIME) . ")";
$db->query($sql);
}
}
}
 

Warning: Unknown: open(/var/lib/php5/sessions/sess_rse96au9fcefc51uu0joh2vn91, O_RDWR) failed: Permission denied (13) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5/sessions) in Unknown on line 0