Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

830
 
1420
 
1420
 
shopping_cart.php
_> 11 <?php
  22 /*
<> 3 -  $Id: shopping_cart.php 830 2006-08-29 12:44:39Z hpdl $
   3+  $Id: shopping_cart.php 1420 2007-03-08 00:21:12Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2006 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
     
 !
1717         $_weight = 0,
  1818         $_tax = 0,
  1919         $_tax_groups = array(),
<> 20 -        $_cartID,
2120         $_content_type,
  2221         $_products_in_stock = true;
  2322 
     
 !
3130                                                    'tax_groups' => array(),
  3231                                                    'shipping_boxes_weight' => 0,
  3332                                                    'shipping_boxes' => 1,
<> 34 -                                                   'cart_id' => $this->generateCartID(),
3533                                                    'shipping_address' => array('zone_id' => STORE_ZONE, 'country_id' => STORE_COUNTRY),
  3634                                                    'shipping_method' => array(),
  3735                                                    'billing_address' => array('zone_id' => STORE_ZONE, 'country_id' => STORE_COUNTRY),
  3836                                                    'billing_method' => array(),
<>  37+                                                   'shipping_quotes' => array(),
3938                                                    'order_totals' => array());
  4039 
  4140         $this->resetShippingAddress();
     
 !
5049       $this->_tax_groups =& $_SESSION['osC_ShoppingCart_data']['tax_groups'];
  5150       $this->_shipping_boxes_weight =& $_SESSION['osC_ShoppingCart_data']['shipping_boxes_weight'];
  5251       $this->_shipping_boxes =& $_SESSION['osC_ShoppingCart_data']['shipping_boxes'];
<> 53 -      $this->_cartID =& $_SESSION['osC_ShoppingCart_data']['cart_id'];
5452       $this->_shipping_address =& $_SESSION['osC_ShoppingCart_data']['shipping_address'];
  5553       $this->_shipping_method =& $_SESSION['osC_ShoppingCart_data']['shipping_method'];
  5654       $this->_billing_address =& $_SESSION['osC_ShoppingCart_data']['billing_address'];
  5755       $this->_billing_method =& $_SESSION['osC_ShoppingCart_data']['billing_method'];
<>  56+      $this->_shipping_quotes =& $_SESSION['osC_ShoppingCart_data']['shipping_quotes'];
5857       $this->_order_totals =& $_SESSION['osC_ShoppingCart_data']['order_totals'];
  5958     }
  6059 
<>  60+    function update() {
   61+      if ( !isset($_SESSION['cartID']) ) {
   62+        $this->_calculate();
   63+      }
   64+    }
   65+
6166     function hasContents() {
  6267       return !empty($this->_contents);
  6368     }
     
 !
203208       $this->_weight = 0;
  204209       $this->_tax = 0;
  205210       $this->_tax_groups = array();
<> 206 -      $this->_cartID = $this->generateCartID();
207211       $this->_content_type = null;
  208212 
  209213       $this->resetShippingAddress();
  210214       $this->resetShippingMethod();
  211215       $this->resetBillingAddress();
  212216       $this->resetBillingMethod();
<>  217+
   218+      if ( isset($_SESSION['cartID']) ) {
   219+        unset($_SESSION['cartID']);
   220+      }
213221     }
  214222 
  215223     function add($products_id_string, $attributes = null, $quantity = null) {
     
 !
390398       return osc_create_random_string($length, 'digits');
  391399     }
  392400 
<> 393 -    function hasCartID() {
  394 -      return isset($this->_cartID);
  395 -    }
  396 -
397401     function getCartID() {
<> 398 -      return $this->_cartID;
   402+      return $_SESSION['cartID'];
399403     }
  400404 
  401405     function getContentType() {
     
 !
728732       $this->_weight = 0;
  729733       $this->_tax = 0;
  730734       $this->_tax_groups = array();
<> 731 -      $this->_cartID = $this->generateCartID();
   735+      $this->_shipping_boxes_weight = 0;
   736+      $this->_shipping_boxes = 0;
   737+      $this->_shipping_quotes = array();
   738+      $this->_order_totals = array();
732739 
<>  740+      $_SESSION['cartID'] = $this->generateCartID();
   741+
733742       if ($this->hasContents()) {
  734743         foreach ($this->_contents as $data) {
  735744           $products_weight = $osC_Weight->convert($data['weight'], $data['weight_class_id'], SHIPPING_WEIGHT_UNIT);
     
 !
759768             $this->_tax_groups[$tax_description] = $tax_amount;
  760769           }
  761770         }
<> 762 -      }
763771 
<> 764 -      $this->_shipping_boxes_weight = $this->_weight;
  765 -      $this->_shipping_boxes = 1;
   772+        $this->_shipping_boxes_weight = $this->_weight;
   773+        $this->_shipping_boxes = 1;
766774 
<> 767 -      if (SHIPPING_BOX_WEIGHT >= ($this->_shipping_boxes_weight * SHIPPING_BOX_PADDING/100)) {
  768 -        $this->_shipping_boxes_weight = $this->_shipping_boxes_weight + SHIPPING_BOX_WEIGHT;
  769 -      } else {
  770 -        $this->_shipping_boxes_weight = $this->_shipping_boxes_weight + ($this->_shipping_boxes_weight * SHIPPING_BOX_PADDING/100);
  771 -      }
   775+        if (SHIPPING_BOX_WEIGHT >= ($this->_shipping_boxes_weight * SHIPPING_BOX_PADDING/100)) {
   776+          $this->_shipping_boxes_weight = $this->_shipping_boxes_weight + SHIPPING_BOX_WEIGHT;
   777+        } else {
   778+          $this->_shipping_boxes_weight = $this->_shipping_boxes_weight + ($this->_shipping_boxes_weight * SHIPPING_BOX_PADDING/100);
   779+        }
772780 
<> 773 -      if ($this->_shipping_boxes_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
  774 -        $this->_shipping_boxes = ceil($this->_shipping_boxes_weight / SHIPPING_MAX_WEIGHT);
  775 -        $this->_shipping_boxes_weight = $this->_shipping_boxes_weight / $this->_shipping_boxes;
  776 -      }
   781+        if ($this->_shipping_boxes_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
   782+          $this->_shipping_boxes = ceil($this->_shipping_boxes_weight / SHIPPING_MAX_WEIGHT);
   783+          $this->_shipping_boxes_weight = $this->_shipping_boxes_weight / $this->_shipping_boxes;
   784+        }
777785 
<> 778 -      if ($set_shipping === true) {
  779 -        if (!class_exists('osC_Shipping')) {
  780 -          include('includes/classes/shipping.php');
   786+        if ($set_shipping === true) {
   787+          if (!class_exists('osC_Shipping')) {
   788+            include('includes/classes/shipping.php');
   789+          }
   790+
   791+          if (!$this->hasShippingMethod() || ($this->getShippingMethod('is_cheapest') === true)) {
   792+            $osC_Shipping = new osC_Shipping();
   793+            $this->setShippingMethod($osC_Shipping->getCheapestQuote(), false);
   794+          } else {
   795+            $osC_Shipping = new osC_Shipping($this->getShippingMethod('id'));
   796+            $this->setShippingMethod($osC_Shipping->getQuote(), false);
   797+          }
781798         }
  782799 
<> 783 -        if (!$this->hasShippingMethod() || ($this->getShippingMethod('is_cheapest') === true)) {
  784 -          $osC_Shipping = new osC_Shipping();
  785 -          $this->setShippingMethod($osC_Shipping->getCheapestQuote(), false);
  786 -        } else {
  787 -          $osC_Shipping = new osC_Shipping($this->getShippingMethod('id'));
  788 -          $this->setShippingMethod($osC_Shipping->getQuote(), false);
   800+        if (!class_exists('osC_OrderTotal')) {
   801+          include('includes/classes/order_total.php');
789802         }
<> 790 -      }
791803 
<> 792 -      if (!class_exists('osC_OrderTotal')) {
  793 -        include('includes/classes/order_total.php');
   804+        $osC_OrderTotal = new osC_OrderTotal();
   805+        $this->_order_totals = $osC_OrderTotal->getResult();
794806       }
<> 795 -
  796 -      $osC_OrderTotal = new osC_OrderTotal();
  797 -      $this->_order_totals = $osC_OrderTotal->getResult();
<_ 798807     }
  799808 
  800809     function _uasortProductsByDateAdded($a, $b) {