Mage_Checkout_Model_Session Class Reference

Inheritance diagram for Mage_Checkout_Model_Session:

Mage_Core_Model_Session_Abstract Mage_Core_Model_Session_Abstract_Varien Varien_Object

List of all members.

Public Member Functions

 __construct ()
 unsetAll ()
 getQuote ()
 setQuoteId ($quoteId)
 getQuoteId ()
 loadCustomerQuote ()
 setStepData ($step, $data, $value=null)
 getStepData ($step=null, $data=null)
 clear ()
 resetCheckout ()
 replaceQuote ($quote)

Public Attributes

const CHECKOUT_STATE_BEGIN = 'begin'

Protected Member Functions

 _getQuoteIdKey ()

Protected Attributes

 $_quote = null


Detailed Description

Definition at line 28 of file Session.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 33 of file Session.php.

00034     {
00035         $this->init('checkout');
00036     }


Member Function Documentation

_getQuoteIdKey (  )  [protected]

Definition at line 91 of file Session.php.

00092     {
00093         return 'quote_id_' . Mage::app()->getStore()->getWebsiteId();
00094     }

clear (  ) 

Alias for unsetAll

Returns:
Mage_Core_Model_Session_Abstract_Varien

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 172 of file Session.php.

00173     {
00174         Mage::dispatchEvent('checkout_quote_destroy', array('quote'=>$this->getQuote()));
00175         $this->_quote = null;
00176         $this->setQuoteId(null);
00177         $this->setLastSuccessQuoteId(null);
00178     }

getQuote (  ) 

Get checkout quote instance by current session

Returns:
Mage_Sales_Model_Quote

Definition at line 49 of file Session.php.

00050     {
00051         if ($this->_quote === null) {
00052             $quote = Mage::getModel('sales/quote')
00053                 ->setStoreId(Mage::app()->getStore()->getId());
00054 
00055             /* @var $quote Mage_Sales_Model_Quote */
00056             if ($this->getQuoteId()) {
00057                 $quote->load($this->getQuoteId());
00058                 if (!$quote->getId()) {
00059                     $this->setQuoteId(null);
00060                 }
00061             }
00062 
00063             $customerSession = Mage::getSingleton('customer/session');
00064 
00065             if (!$this->getQuoteId()) {
00066                 if ($customerSession->isLoggedIn()) {
00067                     $quote->loadByCustomer($customerSession->getCustomer());
00068                     $this->setQuoteId($quote->getId());
00069                 } else {
00070                     $quote->setIsCheckoutCart(true);
00071                     Mage::dispatchEvent('checkout_quote_init', array('quote'=>$quote));
00072                 }
00073             }
00074 
00075             if ($this->getQuoteId()) {
00076                 if ($customerSession->isLoggedIn()) {
00077                     $quote->setCustomer($customerSession->getCustomer());
00078                 }
00079             }
00080 
00081             $quote->setStore(Mage::app()->getStore());
00082             $this->_quote = $quote;
00083         }
00084 
00085         if (isset($_SERVER['REMOTE_ADDR'])) {
00086             $this->_quote->setRemoteIp($_SERVER['REMOTE_ADDR']);
00087         }
00088         return $this->_quote;
00089     }

getQuoteId (  ) 

Definition at line 101 of file Session.php.

00102     {
00103         return $this->getData($this->_getQuoteIdKey());
00104     }

getStepData ( step = null,
data = null 
)

Definition at line 154 of file Session.php.

00155     {
00156         $steps = $this->getSteps();
00157         if (is_null($step)) {
00158             return $steps;
00159         }
00160         if (!isset($steps[$step])) {
00161             return false;
00162         }
00163         if (is_null($data)) {
00164             return $steps[$step];
00165         }
00166         if (!is_string($data) || !isset($steps[$step][$data])) {
00167             return false;
00168         }
00169         return $steps[$step][$data];
00170     }

loadCustomerQuote (  ) 

Load data for customer quote and merge with current quote

Returns:
Mage_Checkout_Model_Session

Definition at line 111 of file Session.php.

00112     {
00113         $customerQuote = Mage::getModel('sales/quote')
00114             ->setStoreId(Mage::app()->getStore()->getId())
00115             ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomerId());
00116 
00117         if ($this->getQuoteId() != $customerQuote->getId()) {
00118             if ($this->getQuoteId()) {
00119                 $customerQuote->merge($this->getQuote())
00120                     ->collectTotals()
00121                     ->save();
00122             }
00123 
00124             $this->setQuoteId($customerQuote->getId());
00125 
00126             if ($this->_quote) {
00127                 $this->_quote->delete();
00128             }
00129             $this->_quote = $customerQuote;
00130         }
00131         return $this;
00132     }

replaceQuote ( quote  ) 

Definition at line 186 of file Session.php.

00187     {
00188         $this->_quote = $quote;
00189         $this->setQuoteId($quote->getId());
00190         return $this;
00191     }

resetCheckout (  ) 

Definition at line 180 of file Session.php.

00181     {
00182         $this->setCheckoutState(self::CHECKOUT_STATE_BEGIN);
00183         return $this;
00184     }

setQuoteId ( quoteId  ) 

Definition at line 96 of file Session.php.

00097     {
00098         $this->setData($this->_getQuoteIdKey(), $quoteId);
00099     }

setStepData ( step,
data,
value = null 
)

Definition at line 134 of file Session.php.

00135     {
00136         $steps = $this->getSteps();
00137         if (is_null($value)) {
00138             if (is_array($data)) {
00139                 $steps[$step] = $data;
00140             }
00141         } else {
00142             if (!isset($steps[$step])) {
00143                 $steps[$step] = array();
00144             }
00145             if (is_string($data)) {
00146                 $steps[$step][$data] = $value;
00147             }
00148         }
00149         $this->setSteps($steps);
00150 
00151         return $this;
00152     }

unsetAll (  ) 

Unset all data

Returns:
Mage_Core_Model_Session_Abstract_Varien

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 38 of file Session.php.

00039     {
00040         parent::unsetAll();
00041         $this->_quote = null;
00042     }


Member Data Documentation

$_quote = null [protected]

Definition at line 31 of file Session.php.

const CHECKOUT_STATE_BEGIN = 'begin'

Definition at line 30 of file Session.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:51 2009 for Magento by  doxygen 1.5.8