logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

[TEP-COMMIT] CVS: catalog/catalog/includes/classes shopping_cart.php,1.35,1: msg#00024

Subject: [TEP-COMMIT] CVS: catalog/catalog/includes/classes shopping_cart.php,1.35,1.36
Update of /cvsroot/tep/catalog/catalog/includes/classes
In directory sc8-pr-cvs1:/tmp/cvs-serv15101/classes

Modified Files:
        shopping_cart.php 
Log Message:
use the new session, customer, and tax classes

remove php 3 compatibility logic


Index: shopping_cart.php
===================================================================
RCS file: /cvsroot/tep/catalog/catalog/includes/classes/shopping_cart.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- shopping_cart.php   25 Jun 2003 21:14:33 -0000      1.35
+++ shopping_cart.php   17 Nov 2003 19:36:56 -0000      1.36
@@ -18,26 +18,26 @@
     }
 
     function restore_contents() {
-      global $customer_id;
+      global $osC_Customer;
 
-      if (!tep_session_is_registered('customer_id')) return false;
+      if ($osC_Customer->isLoggedOn() == false) return false;
 
 // insert current cart contents in database
       if (is_array($this->contents)) {
         reset($this->contents);
         while (list($products_id, ) = each($this->contents)) {
           $qty = $this->contents[$products_id]['qty'];
-          $product_query = tep_db_query("select products_id from " . 
TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and 
products_id = '" . tep_db_input($products_id) . "'");
+          $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)$customer_id . "', '" . 
tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
+            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') . "')");
             if (isset($this->contents[$products_id]['attributes'])) {
               reset($this->contents[$products_id]['attributes']);
               while (list($option, $value) = 
each($this->contents[$products_id]['attributes'])) {
-                tep_db_query("insert into " . 
TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, 
products_options_id, products_options_value_id) values ('" . (int)$customer_id 
. "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . 
(int)$value . "')");
+                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 . "')");
               }
             }
           } else {
-            tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set 
customers_basket_quantity = '" . $qty . "' where customers_id = '" . 
(int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
+            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) . 
"'");
           }
         }
       }
@@ -45,11 +45,11 @@
 // reset per-session cart contents, but not the database contents
       $this->reset(false);
 
-      $products_query = tep_db_query("select products_id, 
customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where 
customers_id = '" . (int)$customer_id . "'");
+      $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']);
 // attributes
-        $attributes_query = tep_db_query("select products_options_id, 
products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where 
customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($products['products_id']) . "'");
+        $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'];
         }
@@ -59,45 +59,43 @@
     }
 
     function reset($reset_database = false) {
-      global $customer_id;
+      global $osC_Session, $osC_Customer;
 
       $this->contents = array();
       $this->total = 0;
       $this->weight = 0;
       $this->content_type = false;
 
-      if (tep_session_is_registered('customer_id') && ($reset_database == 
true)) {
-        tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where 
customers_id = '" . (int)$customer_id . "'");
-        tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " 
where customers_id = '" . (int)$customer_id . "'");
+      if (($reset_database == true) && $osC_Customer->isLoggedOn()) {
+        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 . "'");
       }
 
       unset($this->cartID);
-      if (tep_session_is_registered('cartID')) 
tep_session_unregister('cartID');
+      $osC_Session->remove('cartID');
     }
 
     function add_cart($products_id, $qty = '1', $attributes = '', $notify = 
true) {
-      global $new_products_id_in_cart, $customer_id;
+      global $osC_Session, $osC_Customer;
 
       $products_id = tep_get_uprid($products_id, $attributes);
       if ($notify == true) {
-        $new_products_id_in_cart = $products_id;
-        tep_session_register('new_products_id_in_cart');
+        $osC_Session->set('new_products_id_in_cart', $products_id);
       }
 
       if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
       } else {
-        $this->contents[] = array($products_id);
         $this->contents[$products_id] = array('qty' => $qty);
 // insert into database
-        if (tep_session_is_registered('customer_id')) tep_db_query("insert 
into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, 
customers_basket_quantity, customers_basket_date_added) values ('" . 
(int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', 
'" . date('Ymd') . "')");
+        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) . "', '" . $qty . 
"', '" . date('Ymd') . "')");
 
         if (is_array($attributes)) {
           reset($attributes);
           while (list($option, $value) = each($attributes)) {
             $this->contents[$products_id]['attributes'][$option] = $value;
 // insert into database
-            if (tep_session_is_registered('customer_id')) tep_db_query("insert 
into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, 
products_options_id, products_options_value_id) values ('" . (int)$customer_id 
. "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . 
(int)$value . "')");
+            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) . "', '" . 
(int)$option . "', '" . (int)$value . "')");
           }
         }
       }
@@ -108,41 +106,41 @@
     }
 
     function update_quantity($products_id, $quantity = '', $attributes = '') {
-      global $customer_id;
+      global $osC_Customer;
 
       if (empty($quantity)) return true; // nothing needs to be updated if 
theres no quantity, so we return true..
 
       $this->contents[$products_id] = array('qty' => $quantity);
 // update database
-      if (tep_session_is_registered('customer_id')) tep_db_query("update " . 
TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' 
where customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($products_id) . "'");
+      if ($osC_Customer->isLoggedOn()) tep_db_query("update " . 
TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' 
where customers_id = '" . (int)$osC_Customer->id . "' and products_id = '" . 
tep_db_input($products_id) . "'");
 
       if (is_array($attributes)) {
         reset($attributes);
         while (list($option, $value) = each($attributes)) {
           $this->contents[$products_id]['attributes'][$option] = $value;
 // update database
-          if (tep_session_is_registered('customer_id')) tep_db_query("update " 
. TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . 
(int)$value . "' where customers_id = '" . (int)$customer_id . "' and 
products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" 
. (int)$option . "'");
+          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) . "' and products_options_id = '" 
. (int)$option . "'");
         }
       }
     }
 
     function cleanup() {
-      global $customer_id;
+      global $osC_Customer;
 
       reset($this->contents);
       while (list($key,) = each($this->contents)) {
         if ($this->contents[$key]['qty'] < 1) {
           unset($this->contents[$key]);
 // remove from database
-          if (tep_session_is_registered('customer_id')) {
-            tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where 
customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($key) . "'");
-            tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . 
" where customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($key) . "'");
+          if ($osC_Customer->isLoggedOn()) {
+            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) . "'");
           }
         }
       }
     }
 
-    function count_contents() {  // get total number of items in cart 
+    function count_contents() {  // get total number of items in cart
       $total_items = 0;
       if (is_array($this->contents)) {
         reset($this->contents);
@@ -171,13 +169,13 @@
     }
 
     function remove($products_id) {
-      global $customer_id;
+      global $osC_Customer;
 
       unset($this->contents[$products_id]);
 // remove from database
-      if (tep_session_is_registered('customer_id')) {
-        tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where 
customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($products_id) . "'");
-        tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " 
where customers_id = '" . (int)$customer_id . "' and products_id = '" . 
tep_db_input($products_id) . "'");
+      if ($osC_Customer->isLoggedOn()) {
+        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) . "'");
       }
 
 // assign a temporary unique ID to the order contents to prevent hack attempts 
during the checkout procedure
@@ -201,6 +199,8 @@
     }
 
     function calculate() {
+      global $osC_Tax;
+
       $this->total = 0;
       $this->weight = 0;
       if (!is_array($this->contents)) return 0;
@@ -213,7 +213,7 @@
         $product_query = tep_db_query("select products_id, products_price, 
products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where 
products_id = '" . (int)$products_id . "'");
         if ($product = tep_db_fetch_array($product_query)) {
           $prid = $product['products_id'];
-          $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
+          $products_tax = 
$osC_Tax->getTaxRate($product['products_tax_class_id']);
           $products_price = $product['products_price'];
           $products_weight = $product['products_weight'];
 
@@ -263,14 +263,14 @@
     }
 
     function get_products() {
-      global $languages_id;
+      global $osC_Session;
 
       if (!is_array($this->contents)) return false;
 
       $products_array = array();
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
-        $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)$languages_id . "'");
+        $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'];
@@ -368,14 +368,5 @@
 
       return $this->content_type;
     }
-
-    function unserialize($broken) {
-      for(reset($broken);$kv=each($broken);) {
-        $key=$kv['key'];
-        if (gettype($this->$key)!="user function")
-        $this->$key=$kv['value'];
-      }
-    }
-
   }
 ?>



-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe