Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Checkout_Block_Agreements
  • Mage_Checkout_Block_Cart
  • Mage_Checkout_Block_Cart_Abstract
  • Mage_Checkout_Block_Cart_Coupon
  • Mage_Checkout_Block_Cart_Crosssell
  • Mage_Checkout_Block_Cart_Item_Configure
  • Mage_Checkout_Block_Cart_Item_Renderer
  • Mage_Checkout_Block_Cart_Item_Renderer_Configurable
  • Mage_Checkout_Block_Cart_Item_Renderer_Grouped
  • Mage_Checkout_Block_Cart_Shipping
  • Mage_Checkout_Block_Cart_Sidebar
  • Mage_Checkout_Block_Cart_Totals
  • Mage_Checkout_Block_Links
  • Mage_Checkout_Block_Multishipping_Abstract
  • Mage_Checkout_Block_Multishipping_Address_Select
  • Mage_Checkout_Block_Multishipping_Addresses
  • Mage_Checkout_Block_Multishipping_Billing
  • Mage_Checkout_Block_Multishipping_Billing_Items
  • Mage_Checkout_Block_Multishipping_Link
  • Mage_Checkout_Block_Multishipping_Overview
  • Mage_Checkout_Block_Multishipping_Payment_Info
  • Mage_Checkout_Block_Multishipping_Shipping
  • Mage_Checkout_Block_Multishipping_State
  • Mage_Checkout_Block_Multishipping_Success
  • Mage_Checkout_Block_Onepage
  • Mage_Checkout_Block_Onepage_Abstract
  • Mage_Checkout_Block_Onepage_Billing
  • Mage_Checkout_Block_Onepage_Failure
  • Mage_Checkout_Block_Onepage_Link
  • Mage_Checkout_Block_Onepage_Login
  • Mage_Checkout_Block_Onepage_Payment
  • Mage_Checkout_Block_Onepage_Payment_Info
  • Mage_Checkout_Block_Onepage_Payment_Methods
  • Mage_Checkout_Block_Onepage_Progress
  • Mage_Checkout_Block_Onepage_Review
  • Mage_Checkout_Block_Onepage_Review_Info
  • Mage_Checkout_Block_Onepage_Shipping
  • Mage_Checkout_Block_Onepage_Shipping_Method
  • Mage_Checkout_Block_Onepage_Shipping_Method_Additional
  • Mage_Checkout_Block_Onepage_Shipping_Method_Available
  • Mage_Checkout_Block_Onepage_Success
  • Mage_Checkout_Block_Success
  • Mage_Checkout_Block_Total_Default
  • Mage_Checkout_Block_Total_Nominal
  • Mage_Checkout_Block_Total_Tax
  • Mage_Checkout_CartController
  • Mage_Checkout_Controller_Action
  • Mage_Checkout_Exception
  • Mage_Checkout_Helper_Cart
  • Mage_Checkout_Helper_Data
  • Mage_Checkout_Helper_Url
  • Mage_Checkout_IndexController
  • Mage_Checkout_Model_Agreement
  • Mage_Checkout_Model_Api_Resource
  • Mage_Checkout_Model_Api_Resource_Customer
  • Mage_Checkout_Model_Api_Resource_Product
  • Mage_Checkout_Model_Cart
  • Mage_Checkout_Model_Cart_Api
  • Mage_Checkout_Model_Cart_Api_V2
  • Mage_Checkout_Model_Cart_Coupon_Api
  • Mage_Checkout_Model_Cart_Coupon_Api_V2
  • Mage_Checkout_Model_Cart_Customer_Api
  • Mage_Checkout_Model_Cart_Customer_Api_V2
  • Mage_Checkout_Model_Cart_Payment_Api
  • Mage_Checkout_Model_Cart_Payment_Api_V2
  • Mage_Checkout_Model_Cart_Product_Api
  • Mage_Checkout_Model_Cart_Product_Api_V2
  • Mage_Checkout_Model_Cart_Shipping_Api
  • Mage_Checkout_Model_Cart_Shipping_Api_V2
  • Mage_Checkout_Model_Config_Source_Cart_Summary
  • Mage_Checkout_Model_Mysql4_Agreement
  • Mage_Checkout_Model_Mysql4_Agreement_Collection
  • Mage_Checkout_Model_Mysql4_Cart
  • Mage_Checkout_Model_Mysql4_Setup
  • Mage_Checkout_Model_Observer
  • Mage_Checkout_Model_Resource_Agreement
  • Mage_Checkout_Model_Resource_Agreement_Collection
  • Mage_Checkout_Model_Resource_Cart
  • Mage_Checkout_Model_Resource_Setup
  • Mage_Checkout_Model_Session
  • Mage_Checkout_Model_Type_Abstract
  • Mage_Checkout_Model_Type_Multishipping
  • Mage_Checkout_Model_Type_Multishipping_State
  • Mage_Checkout_Model_Type_Onepage
  • Mage_Checkout_Multishipping_AddressController
  • Mage_Checkout_MultishippingController
  • Mage_Checkout_OnepageController

Interfaces

  • Mage_Checkout_Model_Cart_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Checkout
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Wishlist sidebar block
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Checkout
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Checkout_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Abstract
 36: {
 37:     const XML_PATH_CHECKOUT_SIDEBAR_COUNT   = 'checkout/sidebar/count';
 38: 
 39:     /**
 40:      * Class constructor
 41:      */
 42:     public function __construct()
 43:     {
 44:         parent::__construct();
 45:         $this->addItemRender('default', 'checkout/cart_item_renderer', 'checkout/cart/sidebar/default.phtml');
 46:     }
 47: 
 48:     /**
 49:      * Retrieve count of display recently added items
 50:      *
 51:      * @return int
 52:      */
 53:     public function getItemCount()
 54:     {
 55:         $count = $this->getData('item_count');
 56:         if (is_null($count)) {
 57:             $count = Mage::getStoreConfig(self::XML_PATH_CHECKOUT_SIDEBAR_COUNT);
 58:             $this->setData('item_count', $count);
 59:         }
 60:         return $count;
 61:     }
 62: 
 63:     /**
 64:      * Get array of last added items
 65:      *
 66:      * @return array
 67:      */
 68:     public function getRecentItems($count = null)
 69:     {
 70:         if ($count === null) {
 71:             $count = $this->getItemCount();
 72:         }
 73: 
 74:         $items = array();
 75:         if (!$this->getSummaryCount()) {
 76:             return $items;
 77:         }
 78: 
 79:         $i = 0;
 80:         $allItems = array_reverse($this->getItems());
 81:         foreach ($allItems as $item) {
 82:             /* @var $item Mage_Sales_Model_Quote_Item */
 83:             if (!$item->getProduct()->isVisibleInSiteVisibility()) {
 84:                 $productId = $item->getProduct()->getId();
 85:                 $products  = Mage::getResourceSingleton('catalog/url')
 86:                     ->getRewriteByProductStore(array($productId => $item->getStoreId()));
 87:                 if (!isset($products[$productId])) {
 88:                     continue;
 89:                 }
 90:                 $urlDataObject = new Varien_Object($products[$productId]);
 91:                 $item->getProduct()->setUrlDataObject($urlDataObject);
 92:             }
 93: 
 94:             $items[] = $item;
 95:             if (++$i == $count) {
 96:                 break;
 97:             }
 98:         }
 99: 
100:         return $items;
101:     }
102: 
103:     /**
104:      * Get shopping cart subtotal.
105:      *
106:      * It will include tax, if required by config settings.
107:      *
108:      * @param   bool $skipTax flag for getting price with tax or not. Ignored in case when we display just subtotal incl.tax
109:      * @return  decimal
110:      */
111:     public function getSubtotal($skipTax = true)
112:     {
113:         $subtotal = 0;
114:         $totals = $this->getTotals();
115:         $config = Mage::getSingleton('tax/config');
116:         if (isset($totals['subtotal'])) {
117:             if ($config->displayCartSubtotalBoth()) {
118:                 if ($skipTax) {
119:                     $subtotal = $totals['subtotal']->getValueExclTax();
120:                 } else {
121:                     $subtotal = $totals['subtotal']->getValueInclTax();
122:                 }
123:             } elseif($config->displayCartSubtotalInclTax()) {
124:                 $subtotal = $totals['subtotal']->getValueInclTax();
125:             } else {
126:                 $subtotal = $totals['subtotal']->getValue();
127:                 if (!$skipTax && isset($totals['tax'])) {
128:                     $subtotal+= $totals['tax']->getValue();
129:                 }
130:             }
131:         }
132:         return $subtotal;
133:     }
134: 
135:     /**
136:      * Get subtotal, including tax.
137:      * Will return > 0 only if appropriate config settings are enabled.
138:      *
139:      * @return decimal
140:      */
141:     public function getSubtotalInclTax()
142:     {
143:         if (!Mage::getSingleton('tax/config')->displayCartSubtotalBoth()) {
144:             return 0;
145:         }
146:         return $this->getSubtotal(false);
147:     }
148: 
149:     /**
150:      * Add tax to amount
151:      *
152:      * @param float $price
153:      * @param bool $exclShippingTax
154:      * @return float
155:      */
156:     private function _addTax($price, $exclShippingTax=true) {
157:         $totals = $this->getTotals();
158:         if (isset($totals['tax'])) {
159:             if ($exclShippingTax) {
160:                 $price += $totals['tax']->getValue()-$this->_getShippingTaxAmount();
161:             } else {
162:                 $price += $totals['tax']->getValue();
163:             }
164:         }
165:         return $price;
166:     }
167: 
168:     /**
169:      * Get shipping tax amount
170:      *
171:      * @return float
172:      */
173:     protected function _getShippingTaxAmount()
174:     {
175:         $quote = $this->getCustomQuote() ? $this->getCustomQuote() : $this->getQuote();
176:         return $quote->getShippingAddress()->getShippingTaxAmount();
177:     }
178: 
179:     /**
180:      * Get shopping cart items qty based on configuration (summary qty or items qty)
181:      *
182:      * @return int | float
183:      */
184:     public function getSummaryCount()
185:     {
186:         if ($this->getData('summary_qty')) {
187:             return $this->getData('summary_qty');
188:         }
189:         return Mage::getSingleton('checkout/cart')->getSummaryQty();
190:     }
191: 
192:     /**
193:      * Get incl/excl tax label
194:      *
195:      * @param bool $flag
196:      * @return string
197:      */
198:     public function getIncExcTax($flag)
199:     {
200:         $text = Mage::helper('tax')->getIncExcText($flag);
201:         return $text ? ' ('.$text.')' : '';
202:     }
203: 
204:     /**
205:      * Check if one page checkout is available
206:      *
207:      * @return bool
208:      */
209:     public function isPossibleOnepageCheckout()
210:     {
211:         return $this->helper('checkout')->canOnepageCheckout() && !$this->getQuote()->getHasError();
212:     }
213: 
214:     /**
215:      * Get one page checkout page url
216:      *
217:      * @return bool
218:      */
219:     public function getCheckoutUrl()
220:     {
221:         return $this->helper('checkout/url')->getCheckoutUrl();
222:     }
223: 
224:     /**
225:      * Define if Shopping Cart Sidebar enabled
226:      *
227:      * @return bool
228:      */
229:     public function getIsNeedToDisplaySideBar()
230:     {
231:         return (bool) Mage::app()->getStore()->getConfig('checkout/sidebar/display');
232:     }
233: 
234:     /**
235:      * Return customer quote items
236:      *
237:      * @return array
238:      */
239:     public function getItems()
240:     {
241:         if ($this->getCustomQuote()) {
242:             return $this->getCustomQuote()->getAllVisibleItems();
243:         }
244: 
245:         return parent::getItems();
246:     }
247: 
248:     /*
249:      * Return totals from custom quote if needed
250:      *
251:      * @return array
252:      */
253:     public function getTotalsCache()
254:     {
255:         if (empty($this->_totals)) {
256:             $quote = $this->getCustomQuote() ? $this->getCustomQuote() : $this->getQuote();
257:             $this->_totals = $quote->getTotals();
258:         }
259:         return $this->_totals;
260:     }
261: 
262:     /**
263:      * Get cache key informative items
264:      *
265:      * @return array
266:      */
267:     public function getCacheKeyInfo()
268:     {
269:         $cacheKeyInfo = parent::getCacheKeyInfo();
270:         $cacheKeyInfo['item_renders'] = $this->_serializeRenders();
271:         return $cacheKeyInfo;
272:     }
273: 
274:     /**
275:      * Serialize renders
276:      *
277:      * @return string
278:      */
279:     protected function _serializeRenders()
280:     {
281:         $result = array();
282:         foreach ($this->_itemRenders as $type => $renderer) {
283:             $result[] = implode('|', array($type, $renderer['block'], $renderer['template']));
284:         }
285:         return implode('|', $result);
286:     }
287: 
288:     /**
289:      * Deserialize renders from string
290:      *
291:      * @param string $renders
292:      * @return Mage_Checkout_Block_Cart_Sidebar
293:      */
294:     public function deserializeRenders($renders)
295:     {
296:         if (!is_string($renders)) {
297:             return $this;
298:         }
299: 
300:         $renders = explode('|', $renders);
301:         while (!empty($renders)) {
302:             $template = array_pop($renders);
303:             $block = array_pop($renders);
304:             $type = array_pop($renders);
305:             if (!$template || !$block || !$type) {
306:                 continue;
307:             }
308:             $this->addItemRender($type, $block, $template);
309:         }
310: 
311:         return $this;
312:     }
313: }
314: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0