[TEP-COMMIT] [CVS catalog] use the new database class
hpdl-OfajU3CKLf1/[email protected] 25 Feb 2005 03:04:07 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes/classes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">session_compatible.php</a></tt></td><td align="right" id="added">+53</td><td align="right" id="removed">-12</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php?rev=1.7&content-type=text/vnd.viewcvs-markup">1.7</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php.diff?r1=1.7&r2=1.8">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php?rev=1.8&content-type=text/vnd.viewcvs-markup">1.8</a></td></tr>
<tr class="alt"><td><tt><a href="#file2">shopping_cart.php</a></tt></td><td align="right" id="added">+199</td><td align="right" id="removed">-72</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php?rev=1.38&content-type=text/vnd.viewcvs-markup">1.38</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php.diff?r1=1.38&r2=1.39">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php?rev=1.39&content-type=text/vnd.viewcvs-markup">1.39</a></td></tr>
<tr><td><tt><a href="#file3">tax.php</a></tt></td><td align="right" id="added">+28</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php.diff?r1=1.1&r2=1.2">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php?rev=1.2&content-type=text/vnd.viewcvs-markup">1.2</a></td></tr>
<tr><td></td><td align="right" id="added">+280</td><td align="right" id="removed">-94</td><td></td></tr>
</table>
<small id="info">3 modified files</small><br />
<pre class="comment">
use the new database class
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader"><big><b>session_compatible.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php?rev=1.7&content-type=text/vnd.viewcvs-markup">1.7</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php.diff?r1=1.7&r2=1.8">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/session_compatible.php?rev=1.8&content-type=text/vnd.viewcvs-markup">1.8</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.7 -r1.8
--- session_compatible.php 2004/11/24 16:43:02 1.7
+++ session_compatible.php 2005/02/25 03:04:04 1.8
@@ -5,7 +5,7 @@
</small></pre><pre class="diff" id="context"> osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
</pre><pre class="diff" id="removed">- Copyright (c) 200<span id="removedchars">4</span> osCommerce
</pre><pre class="diff" id="added">+ Copyright (c) 200<span id="addedchars">5</span> osCommerce
</pre><pre class="diff" id="context">
Released under the GNU General Public License
*/
</pre><pre class="diff"><small id="info">@@ -221,39 +221,80 @@
</small></pre><pre class="diff" id="context"> }
function _read($key) {
</pre><pre class="diff" id="removed">- $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
- if (tep_db_num_rows($value_query)) {
- $value = tep_db_fetch_array($value_query);
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $value['value'];
</pre><pre class="diff" id="added">+ $Qsession = $osC_Database->query('select value from :table_sessions where sesskey = :sesskey and expiry > :expiry');
+ $Qsession->bindTable(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->bindRaw(':expiry', time());
+ $Qsession->execute();
+
+ if ($Qsession->numberOfRows() > 0) {
+ $value = $Qsession->value('value');
+
+ $Qsession->freeResult();
+
+ return $value;
</pre><pre class="diff" id="context"> }
return false;
}
function _write($key, $value) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
$SESS_LIFE = 1440;
}
$expiry = time() + $SESS_LIFE;
</pre><pre class="diff" id="removed">- $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
- $check = tep_db_fetch_array($check_query);
</pre><pre class="diff" id="added">+ $Qsession = $osC_Database->query('select count(*) as total from :table_sessions where sesskey = :sesskey');
+ $Qsession->bindTable(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->execute();
+
+ if ($Qsession->valueInt('total') > 0) {
+ $Qsession = $osC_Database->query('update :table_sessions set expiry = :expiry, value = :value where sesskey = :sesskey');
+ } else {
+ $Qsession = $osC_Database->query('insert into :table_sessions values (:sesskey, :expiry, :value)');
+ }
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->bindValue(':expiry', $expiry);
+ $Qsession->bindValue(':value', $value);
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if ($check['total'] > 0) {
- return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
</pre><pre class="diff" id="added">+ if ($Qsession->execute()) {
+ $write = true;
</pre><pre class="diff" id="context"> } else {
</pre><pre class="diff" id="removed">- return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
</pre><pre class="diff" id="added">+ $write = false;
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="added">+
+ $Qsession->freeResult();
+
+ return $write;
</pre><pre class="diff" id="context"> }
function _destroy($key) {
</pre><pre class="diff" id="removed">- return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $Qsession = $osC_Database->query('delete from :table_sessions where sesskey = :sesskey');
+ $Qsession->bindTable(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->execute();
+
+ $Qsession->freeResult();
</pre><pre class="diff" id="context"> }
function _gc($maxlifetime) {
</pre><pre class="diff" id="removed">- return tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $Qsession = $osC_Database->query('delete from :table_sessions where expiry < :expiry');
+ $Qsession->bindTable(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':expiry', time());
+ $Qsession->execute();
+
+ $Qsession->freeResult();
</pre><pre class="diff" id="context"> }
}
?>
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader"><big><b>shopping_cart.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php?rev=1.38&content-type=text/vnd.viewcvs-markup">1.38</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php.diff?r1=1.38&r2=1.39">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/shopping_cart.php?rev=1.39&content-type=text/vnd.viewcvs-markup">1.39</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.38 -r1.39
--- shopping_cart.php 2004/04/15 16:05:36 1.38
+++ shopping_cart.php 2005/02/25 03:04:04 1.39
@@ -5,7 +5,7 @@
</small></pre><pre class="diff" id="context"> osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
</pre><pre class="diff" id="removed">- Copyright (c) 200<span id="removedchars">3</span> osCommerce
</pre><pre class="diff" id="added">+ Copyright (c) 200<span id="addedchars">5</span> osCommerce
</pre><pre class="diff" id="context">
Released under the GNU General Public License
*/
</pre><pre class="diff"><small id="info">@@ -18,7 +18,7 @@
</small></pre><pre class="diff" id="context"> }
function restore_contents() {
</pre><pre class="diff" id="removed">- global $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context">
if ($osC_Customer->isLoggedOn() == false) return false;
</pre><pre class="diff"><small id="info">@@ -27,17 +27,41 @@
</small></pre><pre class="diff" id="context"> reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$qty = $this->contents[$products_id]['qty'];
</pre><pre class="diff" id="removed">- $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id) . "'");
- if (!tep_db_num_rows($product_query)) {
- tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$osC_Customer->id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
</pre><pre class="diff" id="added">+
+ $Qproduct = $osC_Database->query('select products_id from :table_customers_basket where customers_id = :customers_id and products_id = :products_id');
+ $Qproduct->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qproduct->bindInt(':customers_id', $osC_Customer->id);
+ $Qproduct->bindValue(':products_id', $products_id);
+ $Qproduct->execute();
+
+ if ($Qproduct->numberOfRows() < 1) {
+ $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :customers_basket_date_added)');
+ $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qnew->bindInt(':customers_id', $osC_Customer->id);
+ $Qnew->bindValue(':products_id', $products_id);
+ $Qnew->bindInt(':customers_basket_quantity', $qty);
+ $Qnew->bindValue(':customers_basket_date_added', date('Ymd'));
+ $Qnew->execute();
+
</pre><pre class="diff" id="context"> if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
</pre><pre class="diff" id="removed">- tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$osC_Customer->id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
</pre><pre class="diff" id="added">+ $Qnew = $osC_Database->query('insert into :table_customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) values (:customers_id, :products_id, :products_options_id, :products_options_value_id)');
+ $Qnew->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qnew->bindInt(':customers_id', $osC_Customer->id);
+ $Qnew->bindValue(':products_id', $products_id);
+ $Qnew->bindInt(':products_options_id', $option);
+ $Qnew->bindInt(':products_options_value_id', $value);
+ $Qnew->execute();
</pre><pre class="diff" id="context"> }
}
} else {
</pre><pre class="diff" id="removed">- tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id) . "'");
</pre><pre class="diff" id="added">+ $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity where customers_id = :customers_id and products_id = :products_id');
+ $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qupdate->bindInt(':customers_basket_quantity', $qty);
+ $Qupdate->bindInt(':customers_id', $osC_Customer->id);
+ $Qupdate->bindValue(':products_id', $products_id);
+ $Qupdate->execute();
</pre><pre class="diff" id="context"> }
}
}
</pre><pre class="diff"><small id="info">@@ -45,13 +69,22 @@
</small></pre><pre class="diff" id="context"> // reset per-session cart contents, but not the database contents
$this->reset(false);
</pre><pre class="diff" id="removed">- $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$osC_Customer->id . "'");
- while ($products = tep_db_fetch_array($products_query)) {
- $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
</pre><pre class="diff" id="added">+ $Qproducts = $osC_Database->query('select products_id, customers_basket_quantity from :table_customers_basket where customers_id = :customers_id');
+ $Qproducts->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qproducts->bindInt(':customers_id', $osC_Customer->id);
+ $Qproducts->execute();
+
+ while ($Qproducts->next()) {
+ $this->contents[$Qproducts->value('products_id')] = array('qty' => $Qproducts->valueInt('customers_basket_quantity'));
</pre><pre class="diff" id="context"> // attributes
</pre><pre class="diff" id="removed">- $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
- while ($attributes = tep_db_fetch_array($attributes_query)) {
- $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
</pre><pre class="diff" id="added">+ $Qattributes = $osC_Database->query('select products_options_id, products_options_value_id from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id');
+ $Qattributes->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qattributes->bindInt(':customers_id', $osC_Customer->id);
+ $Qattributes->bindValue(':products_id', $Qproducts->value('products_id'));
+ $Qattributes->execute();
+
+ while ($Qattributes->next()) {
+ $this->contents[$Qproducts->value('products_id')]['attributes'][$Qattributes->valueInt('products_options_id')] = $Qattributes->valueInt('products_options_value_id');
</pre><pre class="diff" id="context"> }
}
</pre><pre class="diff"><small id="info">@@ -59,7 +92,7 @@
</small></pre><pre class="diff" id="context"> }
function reset($reset_database = false) {
</pre><pre class="diff" id="removed">- global $osC_Session, $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_<span id="addedchars">Database, $osC_</span>Session, $osC_Customer;
</pre><pre class="diff" id="context">
$this->contents = array();
$this->total = 0;
</pre><pre class="diff"><small id="info">@@ -67,8 +100,15 @@
</small></pre><pre class="diff" id="context"> $this->content_type = false;
if (($reset_database == true) && $osC_Customer->isLoggedOn()) {
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$osC_Customer->id . "'");
- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$osC_Customer->id . "'");
</pre><pre class="diff" id="added">+ $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id');
+ $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->execute();
+
+ $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id');
+ $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->execute();
</pre><pre class="diff" id="context"> }
unset($this->cartID);
</pre><pre class="diff"><small id="info">@@ -76,16 +116,18 @@
</small></pre><pre class="diff" id="context"> }
function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
</pre><pre class="diff" id="removed">- global $osC_Session, $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_<span id="addedchars">Database, $osC_</span>Session, $osC_Customer;
</pre><pre class="diff" id="context">
$products_id_string = tep_get_uprid($products_id, $attributes);
$products_id = tep_get_prid($products_id_string);
if (is_numeric($products_id) && is_numeric($qty)) {
</pre><pre class="diff" id="removed">- $check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
- $check_product = tep_db_fetch_array($check_product_query);
</pre><pre class="diff" id="added">+ $Qcheck = $osC_Database->query('select products_status from :table_products where products_id = :products_id');
+ $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcheck->bindInt(':products_id', $products_id);
+ $Qcheck->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (($check_product !== false) && ($check_product['products_status'] == '1')) {
</pre><pre class="diff" id="added">+ if (($check_product !== false) && ($Qcheck->valueInt('products_status') == '1')) {
</pre><pre class="diff" id="context"> if ($notify == true) {
$osC_Session->set('new_products_id_in_cart', $products_id_string);
}
</pre><pre class="diff"><small id="info">@@ -95,14 +137,30 @@
</small></pre><pre class="diff" id="context"> } else {
$this->contents[$products_id_string] = array('qty' => $qty);
// insert into database
</pre><pre class="diff" id="removed">- if ($osC_Customer->isLoggedOn()) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$osC_Customer->id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");
</pre><pre class="diff" id="added">+ if ($osC_Customer->isLoggedOn()) {
+ $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :customers_basket_date_added)');
+ $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qnew->bindInt(':customers_id', $osC_Customer->id);
+ $Qnew->bindValue(':products_id', $products_id_string);
+ $Qnew->bindInt(':customers_basket_quantity', $qty);
+ $Qnew->bindValue(':customers_basket_date_added', date('Ymd'));
+ $Qnew->execute();
+ }
</pre><pre class="diff" id="context">
if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
$this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
</pre><pre class="diff" id="removed">- if ($osC_Customer->isLoggedOn()) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$osC_Customer->id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");
</pre><pre class="diff" id="added">+ if ($osC_Customer->isLoggedOn()) {
+ $Qnew = $osC_Database->query('insert into :table_customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) values (:customers_id, :products_id, :products_options_id, :products_options_value_id)');
+ $Qnew->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qnew->bindInt(':customers_id', $osC_Customer->id);
+ $Qnew->bindValue(':products_id', $products_id_string);
+ $Qnew->bindInt(':products_options_id', $option);
+ $Qnew->bindInt(':products_options_value_id', $value);
+ $Qnew->execute();
+ }
</pre><pre class="diff" id="context"> }
}
}
</pre><pre class="diff"><small id="info">@@ -116,7 +174,7 @@
</small></pre><pre class="diff" id="context"> }
function update_quantity($products_id, $quantity = '', $attributes = '') {
</pre><pre class="diff" id="removed">- global $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context">
$products_id_string = tep_get_uprid($products_id, $attributes);
$products_id = tep_get_prid($products_id_string);
</pre><pre class="diff"><small id="info">@@ -124,21 +182,36 @@
</small></pre><pre class="diff" id="context"> if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {
$this->contents[$products_id_string] = array('qty' => $quantity);
// update database
</pre><pre class="diff" id="removed">- if ($osC_Customer->isLoggedOn()) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id_string) . "'");
</pre><pre class="diff" id="added">+ if ($osC_Customer->isLoggedOn()) {
+ $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity where customers_id = :customers_id and products_id = :products_id');
+ $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qupdate->bindInt(':customers_basket_quantity', $quantity);
+ $Qupdate->bindInt(':customers_id', $osC_Customer->id);
+ $Qupdate->bindValue(':products_id', $products_id_string);
+ $Qupdate->execute();
+ }
</pre><pre class="diff" id="context">
if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
</pre><pre class="diff" id="removed">- if ($osC_Customer->isLoggedOn()) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");
</pre><pre class="diff" id="added">+ if ($osC_Customer->isLoggedOn()) {
+ $Qupdate = $osC_Database->query('update :table_customers_basket_attributes set products_options_value_id = :products_options_value_id where customers_id = :customers_id and products_id = :products_id and products_options_id = :products_options_id');
+ $Qupdate->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qupdate->bindInt(':products_options_value_id', $value);
+ $Qupdate->bindInt(':customers_id', $osC_Customer->id);
+ $Qupdate->bindValue(':products_id', $products_id_string);
+ $Qupdate->bindInt(':products_options_id', $option);
+ $Qupdate->execute();
+ }
</pre><pre class="diff" id="context"> }
}
}
}
function cleanup() {
</pre><pre class="diff" id="removed">- global $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context">
reset($this->contents);
while (list($key,) = each($this->contents)) {
</pre><pre class="diff"><small id="info">@@ -146,8 +219,17 @@
</small></pre><pre class="diff" id="context"> unset($this->contents[$key]);
// remove from database
if ($osC_Customer->isLoggedOn()) {
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($key) . "'");
- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($key) . "'");
</pre><pre class="diff" id="added">+ $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id and products_id = :products_id');
+ $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->bindValue(':products_id', $key);
+ $Qdelete->execute();
+
+ $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id');
+ $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->bindValue(':products_id', $key);
+ $Qdelete->execute();
</pre><pre class="diff" id="context"> }
}
}
</pre><pre class="diff"><small id="info">@@ -182,13 +264,22 @@
</small></pre><pre class="diff" id="context"> }
function remove($products_id) {
</pre><pre class="diff" id="removed">- global $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context">
unset($this->contents[$products_id]);
// remove from database
if ($osC_Customer->isLoggedOn()) {
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id) . "'");
- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . tep_db_input($products_id) . "'");
</pre><pre class="diff" id="added">+ $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id and products_id = :products_id');
+ $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->bindValue(':products_id', $products_id);
+ $Qdelete->execute();
+
+ $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id');
+ $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qdelete->bindInt(':customers_id', $osC_Customer->id);
+ $Qdelete->bindValue(':products_id', $products_id);
+ $Qdelete->execute();
</pre><pre class="diff" id="context"> }
// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
</pre><pre class="diff"><small id="info">@@ -212,7 +303,7 @@
</small></pre><pre class="diff" id="context"> }
function calculate() {
</pre><pre class="diff" id="removed">- global $osC_Tax, $osC_Weight;
</pre><pre class="diff" id="added">+ global $osC_<span id="addedchars">Database, $osC_</span>Tax, $osC_Weight;
</pre><pre class="diff" id="context">
$this->total = 0;
$this->weight = 0;
</pre><pre class="diff"><small id="info">@@ -223,18 +314,26 @@
</small></pre><pre class="diff" id="context"> $qty = $this->contents[$products_id]['qty'];
// products price
</pre><pre class="diff" id="removed">- $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight, products_weight_class from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
- if ($product = tep_db_fetch_array($product_query)) {
- $prid = $product['products_id'];
- $products_tax = $osC_Tax->getTaxRate($product['products_tax_class_id']);
- $products_price = $product['products_price'];
-
- $products_weight = $osC_Weight->convert($product['products_weight'], $product['products_weight_class'], SHIPPING_WEIGHT_UNIT);
-
- $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
- if (tep_db_num_rows ($specials_query)) {
- $specials = tep_db_fetch_array($specials_query);
- $products_price = $specials['specials_new_products_price'];
</pre><pre class="diff" id="added">+ $Qproduct = $osC_Database->query('select products_id, products_price, products_tax_class_id, products_weight, products_weight_class from :table_products where products_id = :products_id');
+ $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproduct->bindInt(':products_id', $products_id);
+ $Qproduct->execute();
+
+ if ($Qproduct->numberOfRows()) {
+ $prid = $Qproduct->valueInt('products_id');
+ $products_tax = $osC_Tax->getTaxRate($Qproduct->valueInt('products_tax_class_id'));
+ $products_price = $Qproduct->value('products_price');
+
+ $products_weight = $osC_Weight->convert($Qproduct->value('products_weight'), $Qproduct->valueInt('products_weight_class'), SHIPPING_WEIGHT_UNIT);
+
+ $Qspecials = $osC_Database->query('select specials_new_products_price from :table_specials where products_id = :products_id and status = :status');
+ $Qspecials->bindTable(':table_specials', TABLE_SPECIALS);
+ $Qspecials->bindInt(':products_id', $prid);
+ $Qspecials->bindInt(':status', 1);
+ $Qspecials->execute();
+
+ if ($Qspecials->numberOfRows()) {
+ $products_price = $Qspecials->value('specials_new_products_price');
</pre><pre class="diff" id="context"> }
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
</pre><pre class="diff"><small id="info">@@ -245,12 +344,17 @@
</small></pre><pre class="diff" id="context"> if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
</pre><pre class="diff" id="removed">- $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
- $attribute_price = tep_db_fetch_array($attribute_price_query);
- if ($attribute_price['price_prefix'] == '+') {
- $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
</pre><pre class="diff" id="added">+ $Qattributes = $osC_Database->query('select options_values_price, price_prefix from :table_products_attributes where products_id = :products_id and options_id = :options_id and options_values_id = :options_values_id');
+ $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+ $Qattributes->bindInt(':products_id', $prid);
+ $Qattributes->bindInt(':options_id', $option);
+ $Qattributes->bindInt(':options_values_id', $value);
+ $Qattributes->execute();
+
+ if ($Qattributes->value('price_prefix') == '+') {
+ $this->total += $qty * tep_add_tax($Qattributes->value('options_values_price'), $products_tax);
</pre><pre class="diff" id="context"> } else {
</pre><pre class="diff" id="removed">- $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
</pre><pre class="diff" id="added">+ $this->total -= $qty * tep_add_tax($Qattributes->value('options_values_price'), $products_tax);
</pre><pre class="diff" id="context"> }
}
}
</pre><pre class="diff"><small id="info">@@ -258,17 +362,24 @@
</small></pre><pre class="diff" id="context"> }
function attributes_price($products_id) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $attributes_price = 0;
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
</pre><pre class="diff" id="removed">- $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
- $attribute_price = tep_db_fetch_array($attribute_price_query);
- if ($attribute_price['price_prefix'] == '+') {
- $attributes_price += $attribute_price['options_values_price'];
</pre><pre class="diff" id="added">+ $Qattributes = $osC_Database->query('select options_values_price, price_prefix from :table_products_attributes where products_id = :products_id and options_id = :options_id and options_values_id = :options_values_id');
+ $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+ $Qattributes->bindInt(':products_id', $products_id);
+ $Qattributes->bindInt(':options_id', $option);
+ $Qattributes->bindInt(':options_values_id', $value);
+ $Qattributes->execute();
+
+ if ($Qattributes->value('price_prefix') == '+') {
+ $attributes_price += $Qattributes->value('options_values_price');
</pre><pre class="diff" id="context"> } else {
</pre><pre class="diff" id="removed">- $attributes_price -= $attribute_price['options_values_price'];
</pre><pre class="diff" id="added">+ $attributes_price -= $Qattributes->value('options_values_price');
</pre><pre class="diff" id="context"> }
}
}
</pre><pre class="diff"><small id="info">@@ -277,33 +388,43 @@
</small></pre><pre class="diff" id="context"> }
function get_products() {
</pre><pre class="diff" id="removed">- global $osC_Session;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Session;
</pre><pre class="diff" id="context">
if (!is_array($this->contents)) return false;
$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
</pre><pre class="diff" id="removed">- $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$osC_Session->value('languages_id') . "'");
- if ($products = tep_db_fetch_array($products_query)) {
- $prid = $products['products_id'];
- $products_price = $products['products_price'];
-
- $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
- if (tep_db_num_rows($specials_query)) {
- $specials = tep_db_fetch_array($specials_query);
- $products_price = $specials['specials_new_products_price'];
</pre><pre class="diff" id="added">+ $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from :table_products p, :table_products_description pd where p.products_id = :products_id and pd.products_id = p.products_id and pd.language_id = :language_id');
+ $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qproducts->bindInt(':products_id', $products_id);
+ $Qproducts->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qproducts->execute();
+
+ if ($Qproducts->numberOfRows()) {
+ $prid = $Qproducts->valueInt('products_id');
+ $products_price = $Qproducts->value('products_price');
+
+ $Qspecials = $osC_Database->query('select specials_new_products_price from :table_specials where products_id = :products_id and status = :status');
+ $Qspecials->bindTable(':table_specials', TABLE_SPECIALS);
+ $Qspecials->bindInt(':products_id', $prid);
+ $Qspecials->bindInt(':status', 1);
+ $Qspecials->execute();
+
+ if ($Qspecials->numberOfRows()) {
+ $products_price = $Qspecials->value('specials_new_products_price');
</pre><pre class="diff" id="context"> }
$products_array[] = array('id' => $products_id,
</pre><pre class="diff" id="removed">- 'name' => $products['products_name'],
- 'model' => $products['products_model'],
- 'image' => $products['products_image'],
</pre><pre class="diff" id="added">+ 'name' => $Qproducts->value('products_name'),
+ 'model' => $Qproducts->value('products_model'),
+ 'image' => $Qproducts->value('products_image'),
</pre><pre class="diff" id="context"> 'price' => $products_price,
'quantity' => $this->contents[$products_id]['qty'],
</pre><pre class="diff" id="removed">- 'weight' => $products['products_weight'],
</pre><pre class="diff" id="added">+ 'weight' => $Qproducts->value('products_weight'),
</pre><pre class="diff" id="context"> 'final_price' => ($products_price + $this->attributes_price($products_id)),
</pre><pre class="diff" id="removed">- 'tax_class_id' => $products['products_tax_class_id'],
</pre><pre class="diff" id="added">+ 'tax_class_id' => $Qproducts->valueInt('products_tax_class_id'),
</pre><pre class="diff" id="context"> 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
}
}
</pre><pre class="diff"><small id="info">@@ -328,6 +449,8 @@
</small></pre><pre class="diff" id="context"> }
function get_content_type() {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $this->content_type = false;
if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
</pre><pre class="diff"><small id="info">@@ -336,10 +459,14 @@
</small></pre><pre class="diff" id="context"> if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
</pre><pre class="diff" id="removed">- $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
- $virtual_check = tep_db_fetch_array($virtual_check_query);
</pre><pre class="diff" id="added">+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products_attributes pa, :table_products_attributes_download pad where pa.products_id = :products_id and pa.options_values_id = :options_values_id and pa.products_attributes_id = pad.products_attributes_id');
+ $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+ $Qcheck->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD);
+ $Qcheck->bindInt(':products_id', $products_id);
+ $Qcheck->bindInt(':options_values_id', $value);
+ $Qcheck->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if ($virtual_check['total'] > 0) {
</pre><pre class="diff" id="added">+ if ($Qcheck->valueInt('total') > 0) {
</pre><pre class="diff" id="context"> switch ($this->content_type) {
case 'physical':
$this->content_type = 'mixed';
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader"><big><b>tax.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php.diff?r1=1.1&r2=1.2">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/tax.php?rev=1.2&content-type=text/vnd.viewcvs-markup">1.2</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- tax.php 2003/11/17 16:56:11 1.1
+++ tax.php 2005/02/25 03:04:04 1.2
@@ -5,7 +5,7 @@
</small></pre><pre class="diff" id="context"> osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
</pre><pre class="diff" id="removed">- Copyright (c) 200<span id="removedchars">3</span> osCommerce
</pre><pre class="diff" id="added">+ Copyright (c) 200<span id="addedchars">5</span> osCommerce
</pre><pre class="diff" id="context">
Released under the GNU General Public License
*/
</pre><pre class="diff"><small id="info">@@ -20,7 +20,7 @@
</small></pre><pre class="diff" id="context">
// class methods
function getTaxRate($class_id, $country_id = -1, $zone_id = -1) {
</pre><pre class="diff" id="removed">- global $osC_Customer;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context">
if ( ($country_id == -1) && ($zone_id == -1) ) {
if ($osC_Customer->isLoggedOn()) {
</pre><pre class="diff"><small id="info">@@ -33,11 +33,19 @@
</small></pre><pre class="diff" id="context"> }
if (isset($this->tax_rates[$class_id][$country_id][$zone_id]['rate']) == false) {
</pre><pre class="diff" id="removed">- $tax_query = tep_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority");
- if (tep_db_num_rows($tax_query)) {
</pre><pre class="diff" id="added">+ $Qtax = $osC_Database->query('select sum(tax_rate) as tax_rate from :table_tax_rates tr left join :table_zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join :table_geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = 0 or za.zone_country_id = :zone_country_id) and (za.zone_id is null or za.zone_id = 0 or za.zone_id = :zone_id) and tr.tax_class_id = :tax_class_id group by tr.tax_priority');
+ $Qtax->bindTable(':table_tax_rates', TABLE_TAX_RATES);
+ $Qtax->bindTable(':table_zones_to_geo_zones', TABLE_ZONES_TO_GEO_ZONES);
+ $Qtax->bindTable(':table_geo_zones', TABLE_GEO_ZONES);
+ $Qtax->bindInt(':zone_country_id', $country_id);
+ $Qtax->bindInt(':zone_id', $zone_id);
+ $Qtax->bindInt(':tax_class_id', $class_id);
+ $Qtax->execute();
+
+ if ($Qtax->numberOfRows()) {
</pre><pre class="diff" id="context"> $tax_multiplier = 1.0;
</pre><pre class="diff" id="removed">- while ($tax = tep_db_fetch_array($tax_query)) {
- $tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100);
</pre><pre class="diff" id="added">+ while ($Qtax->next()) {
+ $tax_multiplier *= 1.0 + ($Qtax->value('tax_rate') / 100);
</pre><pre class="diff" id="context"> }
$tax_rate = ($tax_multiplier - 1.0) * 100;
</pre><pre class="diff"><small id="info">@@ -52,13 +60,23 @@
</small></pre><pre class="diff" id="context"> }
function getTaxRateDescription($class_id, $country_id, $zone_id) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> if (isset($this->tax_rates[$class_id][$country_id][$zone_id]['description']) == false) {
</pre><pre class="diff" id="removed">- $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority");
- if (tep_db_num_rows($tax_query)) {
</pre><pre class="diff" id="added">+ $Qtax = $osC_Database->query('select tax_description from :table_tax_rates tr left join :table_zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join :table_geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = 0 or za.zone_country_id = :zone_country_id) and (za.zone_id is null or za.zone_id = 0 or za.zone_id = :zone_id) and tr.tax_class_id = :tax_class_id group by tr.tax_priority');
+ $Qtax->bindTable(':table_tax_rates', TABLE_TAX_RATES);
+ $Qtax->bindTable(':table_zones_to_geo_zones', TABLE_ZONES_TO_GEO_ZONES);
+ $Qtax->bindTable(':table_geo_zones', TABLE_GEO_ZONES);
+ $Qtax->bindInt(':zone_country_id', $country_id);
+ $Qtax->bindInt(':zone_id', $zone_id);
+ $Qtax->bindInt(':tax_class_id', $class_id);
+ $Qtax->execute();
+
+ if ($Qtax->numberOfRows()) {
</pre><pre class="diff" id="context"> $tax_description = '';
</pre><pre class="diff" id="removed">- while ($tax = tep_db_fetch_array($tax_query)) {
- $tax_description .= $tax['tax_description'] . ' + ';
</pre><pre class="diff" id="added">+ while ($Qtax->next()) {
+ $tax_description .= $Qtax->value('tax_description') . ' + ';
</pre><pre class="diff" id="context"> }
$this->tax_rates[$class_id][$country_id][$zone_id]['description'] = substr($tax_description, 0, -3);
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.9</small></center>
</body></html>
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click