Mage_Sales_Model_Quote_Address_Total_Subtotal Class Reference

Inheritance diagram for Mage_Sales_Model_Quote_Address_Total_Subtotal:

Mage_Sales_Model_Quote_Address_Total_Abstract

List of all members.

Public Member Functions

 collect (Mage_Sales_Model_Quote_Address $address)
 fetch (Mage_Sales_Model_Quote_Address $address)

Protected Member Functions

 _initItem ($address, $item)
 _removeItem ($address, $item)


Detailed Description

Definition at line 28 of file Subtotal.php.


Member Function Documentation

_initItem ( address,
item 
) [protected]

Address item initialization

Parameters:
$item 
Returns:
bool

Quote super mode flag meen whot we work with quote without restriction

Definition at line 73 of file Subtotal.php.

00074     {
00075         if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
00076             $quoteItem = $item->getAddress()->getQuote()->getItemById($item->getQuoteItemId());
00077         }
00078         else {
00079             $quoteItem = $item;
00080         }
00081         $product = $quoteItem->getProduct();
00082         $product->setCustomerGroupId($quoteItem->getQuote()->getCustomerGroupId());
00083 
00084         /**
00085          * Quote super mode flag meen whot we work with quote without restriction
00086          */
00087         if ($item->getQuote()->getIsSuperMode()) {
00088             if (!$product) {
00089                 return false;
00090             }
00091         }
00092         else {
00093             if (!$product || !$product->isVisibleInCatalog()) {
00094                 return false;
00095             }
00096         }
00097 
00098         if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
00099             $finalPrice = $quoteItem->getParentItem()->getProduct()->getPriceModel()->getChildFinalPrice(
00100                $quoteItem->getParentItem()->getProduct(),
00101                $quoteItem->getParentItem()->getQty(),
00102                $quoteItem->getProduct(),
00103                $quoteItem->getQty()
00104             );
00105             $item->setPrice($finalPrice);
00106             $item->calcRowTotal();
00107         }
00108         else if (!$quoteItem->getParentItem()) {
00109             $finalPrice = $product->getFinalPrice($quoteItem->getQty());
00110             $item->setPrice($finalPrice);
00111             $item->calcRowTotal();
00112             $address->setSubtotal($address->getSubtotal() + $item->getRowTotal());
00113             $address->setBaseSubtotal($address->getBaseSubtotal() + $item->getBaseRowTotal());
00114             $address->setTotalQty($address->getTotalQty() + $item->getQty());
00115         }
00116 
00117         return true;
00118     }

_removeItem ( address,
item 
) [protected]

Remove item

Parameters:
$address 
$item 
Returns:
Mage_Sales_Model_Quote_Address_Total_Subtotal

Definition at line 127 of file Subtotal.php.

00128     {
00129         if ($item instanceof Mage_Sales_Model_Quote_Item) {
00130             $address->removeItem($item->getId());
00131             if ($address->getQuote()) {
00132                 $address->getQuote()->removeItem($item->getId());
00133             }
00134         }
00135         elseif ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
00136             $address->removeItem($item->getId());
00137             if ($address->getQuote()) {
00138                 $address->getQuote()->removeItem($item->getQuoteItemId());
00139             }
00140         }
00141 
00142         return $this;
00143     }

collect ( Mage_Sales_Model_Quote_Address address  ) 

Collect address subtotal

Parameters:
Mage_Sales_Model_Quote_Address $address
Returns:
Mage_Sales_Model_Quote_Address_Total_Subtotal

Reset subtotal information

Process address items

Initialize grand totals

Reimplemented from Mage_Sales_Model_Quote_Address_Total_Abstract.

Definition at line 36 of file Subtotal.php.

00037     {
00038         /**
00039          * Reset subtotal information
00040          */
00041         $address->setSubtotal(0);
00042         $address->setBaseSubtotal(0);
00043         $address->setTotalQty(0);
00044         $address->setBaseTotalPriceIncTax(0);
00045 
00046         /**
00047          * Process address items
00048          */
00049         $items = $address->getAllItems();
00050 
00051         foreach ($items as $item) {
00052             if (!$this->_initItem($address, $item) || $item->getQty()<=0) {
00053                 $this->_removeItem($address, $item);
00054             }
00055         }
00056 
00057         /**
00058          * Initialize grand totals
00059          */
00060         $address->setGrandTotal($address->getSubtotal());
00061         $address->setBaseGrandTotal($address->getBaseSubtotal());
00062         Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getSubtotal());
00063         Mage::helper('sales')->checkQuoteAmount($address->getQuote(), $address->getBaseSubtotal());
00064         return $this;
00065     }

fetch ( Mage_Sales_Model_Quote_Address address  ) 

Fetch (Retrieve data as array)

Parameters:
Mage_Sales_Model_Quote_Address $address
Returns:
array

Reimplemented from Mage_Sales_Model_Quote_Address_Total_Abstract.

Definition at line 145 of file Subtotal.php.

00146     {
00147         $address->addTotal(array(
00148             'code'=>$this->getCode(),
00149             'title'=>Mage::helper('sales')->__('Subtotal'),
00150             'value'=>$address->getSubtotal()
00151         ));
00152         return $this;
00153     }


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

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