📄 upgrade_3.php
字号:
$o['id'] = $orders['orders_id'];
$o['shipping_method'] = $orders['shipping_method'];
$o['shipping_cost'] = $orders['shipping_cost'];
$o['currency'] = $orders['currency'];
$o['currency_value'] = $orders['currency_value'];
$o['tax'] = 0;
$orders_products_query = osc_db_query("select final_price, products_tax, products_quantity from orders_products where orders_id = '" . $orders['orders_id'] . "'");
while ($orders_products = osc_db_fetch_array($orders_products_query)) {
$o['products'][$i]['final_price'] = $orders_products['final_price'];
$o['products'][$i]['qty'] = $orders_products['products_quantity'];
$o['products'][$i]['tax_groups']["{$orders_products['products_tax']}"] += $orders_products['products_tax']/100 * ($orders_products['final_price'] * $orders_products['products_quantity']);
$o['tax'] += $orders_products['products_tax']/100 * ($orders_products['final_price'] * $orders_products['products_quantity']);
$total_cost += ($o['products'][$i]['final_price'] * $o['products'][$i]['qty']);
}
$subtotal_text = osc_currency_format($total_cost, true, $o['currency'], $o['currency_value']);
$subtotal_value = $total_cost;
osc_db_query("insert into orders_total (orders_total_id, orders_id, title, text, value, class, sort_order) values ('', '" . $o['id'] . "', 'Sub-Total:', '" . $subtotal_text . "', '" . $subtotal_value . "', 'ot_subtotal', '1')");
$tax_text = osc_currency_format($o['tax'], true, $o['currency'], $o['currency_value']);
$tax_value = $o['tax'];
osc_db_query("insert into orders_total (orders_total_id, orders_id, title, text, value, class, sort_order) values ('', '" . $o['id'] . "', 'Tax:', '" . $tax_text . "', '" . $tax_value . "', 'ot_tax', '2')");
if (strlen($o['shipping_method']) < 1) {
$o['shipping_method'] = 'Shipping:';
} else {
$o['shipping_method'] .= ':';
}
if ($o['shipping_cost'] > 0) {
$shipping_text = osc_currency_format($o['shipping_cost'], true, $o['currency'], $o['currency_value']);
$shipping_value = $o['shipping_cost'];
osc_db_query("insert into orders_total (orders_total_id, orders_id, title, text, value, class, sort_order) values ('', '" . $o['id'] . "', '" . $o['shipping_method'] . "', '" . $shipping_text . "', '" . $shipping_value . "', 'ot_shipping', '3')");
}
$total_text = osc_currency_format($total_cost + $o['tax'] + $o['shipping_cost'], true, $o['currency'], $o['currency_value']);
$total_value = $total_cost + $o['tax'] + $o['shipping_cost'];
osc_db_query("insert into orders_total (orders_total_id, orders_id, title, text, value, class, sort_order) values ('', '" . $o['id'] . "', 'Total:', '" . $total_text . "', '" . $total_value . "', 'ot_total', '4')");
$i++;
}
osc_db_query("alter table orders drop shipping_method");
osc_db_query("alter table orders drop shipping_cost");
?>
<script language="javascript"><!--
changeStyle('orders', 'normal');
changeText('ordersMarker', '*');
changeText('statusText', 'Updating Orders .. done!');
changeStyle('products', 'bold');
changeText('productsMarker', '?');
changeText('statusText', 'Updating Products');
//--></script>
<?php
flush();
osc_db_query("create table products_description ( products_id int(5) not null auto_increment, language_id int(5) not null default '1', products_name varchar(64) not null default '', products_description text, products_url varchar(255), products_viewed int(5) default '0', primary key (products_id, language_id), key products_name (products_name))");
$products_query = osc_db_query("select products_id, products_name, products_description, products_url, products_viewed from products order by products_id");
while ($products = osc_db_fetch_array($products_query)) {
for ($i=0; $i<sizeof($languages); $i++) {
osc_db_query("insert into products_description (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . $products['products_id'] . "', '" . $languages[$i]['id'] . "', '" . addslashes($products['products_name']) . "', '" . addslashes($products['products_description']) . "', '" . addslashes($products['products_url']) . "', '" . $products['products_viewed'] . "')");
}
}
osc_db_query("update products set products_date_added = now() where products_date_added is null");
osc_db_query("alter table products change products_date_added products_date_added datetime not null");
osc_db_query("alter table products change products_price products_price decimal(15,4) not null");
osc_db_query("alter table products add index idx_products_date_added (products_date_added)");
osc_db_query("alter table products drop index products_name");
osc_db_query("alter table products drop products_url");
osc_db_query("alter table products drop products_name");
osc_db_query("alter table products drop products_description");
osc_db_query("alter table products drop products_viewed");
osc_db_query("alter table products add products_date_available datetime");
osc_db_query("alter table products add products_last_modified datetime");
osc_db_query("alter table products add products_ordered int default '0' not null");
$products_query = osc_db_query("select products_id, sum(products_quantity) as products_ordered from orders_products group by products_id");
while ($products = osc_db_fetch_array($products_query)) {
osc_db_query("update products set products_ordered = '" . $products['products_ordered'] . "' where products_id = '" . $products['products_id'] . "'");
}
osc_db_query("drop table products_expected");
osc_db_query("alter table products_attributes change options_values_price options_values_price decimal(15,4) not null");
osc_db_query("alter table products_options change products_options_id products_options_id int(5) not null default '0'");
osc_db_query("alter table products_options add language_id int(5) not null default '1' after products_options_id");
osc_db_query("alter table products_options drop primary key");
osc_db_query("alter table products_options add primary key (products_options_id, language_id)");
$products_query = osc_db_query("select products_options_id, language_id, products_options_name from products_options order by products_options_id");
while ($products = osc_db_fetch_array($products_query)) {
for ($i=0; $i<sizeof($languages); $i++) {
osc_db_query("replace into products_options (products_options_id, language_id, products_options_name) values ('" . $products['products_options_id'] . "', '" . $languages[$i]['id'] . "', '" . addslashes($products['products_options_name']) . "')");
}
}
osc_db_query("alter table products_options_values change products_options_values_id products_options_values_id int(5) not null default '0'");
osc_db_query("alter table products_options_values add language_id int(5) not null default '1' after products_options_values_id");
osc_db_query("alter table products_options_values drop primary key");
osc_db_query("alter table products_options_values add primary key (products_options_values_id, language_id)");
$products_query = osc_db_query("select products_options_values_id, language_id, products_options_values_name from products_options_values order by products_options_values_id");
while ($products = osc_db_fetch_array($products_query)) {
for ($i=0; $i<sizeof($languages); $i++) {
osc_db_query("replace into products_options_values (products_options_values_id, language_id, products_options_values_name) values ('" . $products['products_options_values_id'] . "', '" . $languages[$i]['id'] . "', '" . addslashes($products['products_options_values_name']) . "')");
}
}
osc_db_query("alter table products_to_categories change products_id products_id int(5) not null");
osc_db_query("create table products_attributes_download ( products_attributes_id int(5) not null, products_attributes_filename varchar(255) not null, products_attributes_maxdays int(2) default '0', products_attributes_maxcount int(2) default '0', primary key (products_attributes_id))");
osc_db_query("create table products_notifications ( products_id int(5) not null, customers_id int(5) not null, date_added datetime not null, primary key (products_id, customers_id))");
?>
<script language
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -