Mage_Checkout_Block_Cart_Abstract Class Reference

Inheritance diagram for Mage_Checkout_Block_Cart_Abstract:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Checkout_Block_Cart Mage_Checkout_Block_Cart_Coupon Mage_Checkout_Block_Cart_Shipping Mage_Checkout_Block_Cart_Sidebar Mage_Checkout_Block_Cart_Totals

List of all members.

Public Member Functions

 __construct ()
 addItemRender ($productType, $blockType, $template)
 getItemRender ($type)
 getItemRendererInfo ($type)
 getItemRenderer ($type)
 getCustomer ()
 getCheckout ()
 getQuote ()
 getItems ()
 getItemHtml (Mage_Sales_Model_Quote_Item $item)
 getTotals ()
 getTotalsCache ()

Protected Attributes

 $_customer = null
 $_checkout = null
 $_quote = null
 $_totals
 $_itemRenders = array()


Detailed Description

Definition at line 34 of file Abstract.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.

Reimplemented in Mage_Checkout_Block_Cart_Sidebar.

Definition at line 43 of file Abstract.php.

00044     {
00045         parent::__construct();
00046         $this->addItemRender('default', 'checkout/cart_item_renderer', 'checkout/cart/item/default.phtml');
00047     }


Member Function Documentation

addItemRender ( productType,
blockType,
template 
)

Add renderer for item product type

Parameters:
string $productType
string $blockType
string $template
Returns:
Mage_Checkout_Block_Cart_Abstract

Definition at line 57 of file Abstract.php.

00058     {
00059         $this->_itemRenders[$productType] = array(
00060             'block' => $blockType,
00061             'template' => $template,
00062             'blockInstance' => null
00063         );
00064         return $this;
00065     }

getCheckout (  ) 

Get checkout session

Returns:
Mage_Checkout_Model_session

Definition at line 134 of file Abstract.php.

00135     {
00136         if (null === $this->_checkout) {
00137             $this->_checkout = Mage::getSingleton('checkout/session');
00138         }
00139         return $this->_checkout;
00140     }

getCustomer (  ) 

Get logged in customer

Returns:
Mage_Customer_Model_Customer

Definition at line 121 of file Abstract.php.

00122     {
00123         if (null === $this->_customer) {
00124             $this->_customer = Mage::getSingleton('customer/session')->getCustomer();
00125         }
00126         return $this->_customer;
00127     }

getItemHtml ( Mage_Sales_Model_Quote_Item item  ) 

Get item row html

Parameters:
Mage_Sales_Model_Quote_Item $item
Returns:
string

Definition at line 171 of file Abstract.php.

00172     {
00173         $renderer = $this->getItemRenderer($item->getProductType())->setItem($item);
00174         return $renderer->toHtml();
00175     }

getItemRender ( type  ) 

Get renderer information by product type code

Deprecated:
please use getItemRendererInfo() method instead
See also:
getItemRendererInfo()
Parameters:
string $type
Returns:
array

Definition at line 75 of file Abstract.php.

00076     {
00077         return $this->getItemRendererInfo();
00078     }

getItemRenderer ( type  ) 

Get renderer block instance by product type code

Parameters:
string $type
Returns:
array

Definition at line 100 of file Abstract.php.

00101     {
00102         if (!isset($this->_itemRenders[$type])) {
00103             $type = 'default';
00104         }
00105         if (is_null($this->_itemRenders[$type]['blockInstance'])) {
00106              $this->_itemRenders[$type]['blockInstance'] = $this->getLayout()
00107                 ->createBlock($this->_itemRenders[$type]['block'])
00108                     ->setTemplate($this->_itemRenders[$type]['template'])
00109                     ->setRenderedBlock($this);
00110         }
00111 
00112         return $this->_itemRenders[$type]['blockInstance'];
00113     }

getItemRendererInfo ( type  ) 

Get renderer information by product type code

Parameters:
string $type
Returns:
array

Definition at line 86 of file Abstract.php.

00087     {
00088         if (isset($this->_itemRenders[$type])) {
00089             return $this->_itemRenders[$type];
00090         }
00091         return $this->_itemRenders['default'];
00092      }

getItems (  ) 

Get all cart items

Returns:
array

Definition at line 160 of file Abstract.php.

00161     {
00162         return $this->getQuote()->getAllVisibleItems();
00163     }

getQuote (  ) 

Get active quote

Returns:
Mage_Sales_Model_Quote

Definition at line 147 of file Abstract.php.

00148     {
00149         if (null === $this->_quote) {
00150             $this->_quote = $this->getCheckout()->getQuote();
00151         }
00152         return $this->_quote;
00153     }

getTotals (  ) 

Reimplemented in Mage_Checkout_Block_Cart_Totals.

Definition at line 177 of file Abstract.php.

00178     {
00179         return $this->getTotalsCache();
00180     }

getTotalsCache (  ) 

Definition at line 182 of file Abstract.php.

00183     {
00184         if (empty($this->_totals)) {
00185             $this->_totals = $this->getQuote()->getTotals();
00186         }
00187         return $this->_totals;
00188     }


Member Data Documentation

$_checkout = null [protected]

Definition at line 37 of file Abstract.php.

$_customer = null [protected]

Definition at line 36 of file Abstract.php.

$_itemRenders = array() [protected]

Definition at line 41 of file Abstract.php.

$_quote = null [protected]

Definition at line 38 of file Abstract.php.

$_totals [protected]

Reimplemented in Mage_Checkout_Block_Cart_Totals.

Definition at line 40 of file Abstract.php.


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

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