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:  * Shopping cart item render block
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Checkout
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  *
 34:  * @method Mage_Checkout_Block_Cart_Item_Renderer setProductName(string)
 35:  * @method Mage_Checkout_Block_Cart_Item_Renderer setDeleteUrl(string)
 36:  */
 37: class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
 38: {
 39:     /** @var Mage_Checkout_Model_Session */
 40:     protected $_checkoutSession;
 41:     protected $_item;
 42:     protected $_productUrl = null;
 43:     protected $_productThumbnail = null;
 44: 
 45:     /**
 46:      * Whether qty will be converted to number
 47:      *
 48:      * @var bool
 49:      */
 50:     protected $_strictQtyMode = true;
 51: 
 52:     /**
 53:      * Check, whether product URL rendering should be ignored
 54:      *
 55:      * @var bool
 56:      */
 57:     protected $_ignoreProductUrl = false;
 58: 
 59:     /**
 60:      * Set item for render
 61:      *
 62:      * @param   Mage_Sales_Model_Quote_Item $item
 63:      * @return  Mage_Checkout_Block_Cart_Item_Renderer
 64:      */
 65:     public function setItem(Mage_Sales_Model_Quote_Item_Abstract $item)
 66:     {
 67:         $this->_item = $item;
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * Get quote item
 73:      *
 74:      * @return Mage_Sales_Model_Quote_Item
 75:      */
 76:     public function getItem()
 77:     {
 78:         return $this->_item;
 79:     }
 80: 
 81:     /**
 82:      * Get item product
 83:      *
 84:      * @return Mage_Catalog_Model_Product
 85:      */
 86:     public function getProduct()
 87:     {
 88:         return $this->getItem()->getProduct();
 89:     }
 90: 
 91:     public function overrideProductThumbnail($productThumbnail)
 92:     {
 93:         $this->_productThumbnail = $productThumbnail;
 94:         return $this;
 95:     }
 96: 
 97:     /**
 98:      * Get product thumbnail image
 99:      *
100:      * @return Mage_Catalog_Model_Product_Image
101:      */
102:     public function getProductThumbnail()
103:     {
104:         if (!is_null($this->_productThumbnail)) {
105:             return $this->_productThumbnail;
106:         }
107:         return $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail');
108:     }
109: 
110:     public function overrideProductUrl($productUrl)
111:     {
112:         $this->_productUrl = $productUrl;
113:         return $this;
114:     }
115: 
116:     /**
117:      * Check Product has URL
118:      *
119:      * @return bool
120:      */
121:     public function hasProductUrl()
122:     {
123:         if ($this->_ignoreProductUrl) {
124:             return false;
125:         }
126: 
127:         if ($this->_productUrl || $this->getItem()->getRedirectUrl()) {
128:             return true;
129:         }
130: 
131:         $product = $this->getProduct();
132:         $option  = $this->getItem()->getOptionByCode('product_type');
133:         if ($option) {
134:             $product = $option->getProduct();
135:         }
136: 
137:         if ($product->isVisibleInSiteVisibility()) {
138:             return true;
139:         }
140:         else {
141:             if ($product->hasUrlDataObject()) {
142:                 $data = $product->getUrlDataObject();
143:                 if (in_array($data->getVisibility(), $product->getVisibleInSiteVisibilities())) {
144:                     return true;
145:                 }
146:             }
147:         }
148: 
149:         return false;
150:     }
151: 
152:     /**
153:      * Retrieve URL to item Product
154:      *
155:      * @return string
156:      */
157:     public function getProductUrl()
158:     {
159:         if (!is_null($this->_productUrl)) {
160:             return $this->_productUrl;
161:         }
162:         if ($this->getItem()->getRedirectUrl()) {
163:             return $this->getItem()->getRedirectUrl();
164:         }
165: 
166:         $product = $this->getProduct();
167:         $option  = $this->getItem()->getOptionByCode('product_type');
168:         if ($option) {
169:             $product = $option->getProduct();
170:         }
171: 
172:         return $product->getUrlModel()->getUrl($product);
173:     }
174: 
175:     /**
176:      * Get item product name
177:      *
178:      * @return string
179:      */
180:     public function getProductName()
181:     {
182:         if ($this->hasProductName()) {
183:             return $this->getData('product_name');
184:         }
185:         return $this->getProduct()->getName();
186:     }
187: 
188:     /**
189:      * Get product customize options
190:      *
191:      * @return array || false
192:      */
193:     public function getProductOptions()
194:     {
195:         /* @var $helper Mage_Catalog_Helper_Product_Configuration */
196:         $helper = Mage::helper('catalog/product_configuration');
197:         return $helper->getCustomOptions($this->getItem());
198:     }
199: 
200:     /**
201:      * Get list of all otions for product
202:      *
203:      * @return array
204:      */
205:     public function getOptionList()
206:     {
207:         return $this->getProductOptions();
208:     }
209: 
210:     /**
211:      * Get item configure url
212:      *
213:      * @return string
214:      */
215:     public function getConfigureUrl()
216:     {
217:         return $this->getUrl(
218:             'checkout/cart/configure',
219:             array('id' => $this->getItem()->getId())
220:         );
221:     }
222: 
223:     /**
224:      * Get item delete url
225:      *
226:      * @return string
227:      */
228:     public function getDeleteUrl()
229:     {
230:         if ($this->hasDeleteUrl()) {
231:             return $this->getData('delete_url');
232:         }
233: 
234:         return $this->getUrl(
235:             'checkout/cart/delete',
236:             array(
237:                 'id'=>$this->getItem()->getId(),
238:                 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl()
239:             )
240:         );
241:     }
242: 
243:     /**
244:      * Get quote item qty
245:      *
246:      * @return float|int|string
247:      */
248:     public function getQty()
249:     {
250:         if (!$this->_strictQtyMode && (string)$this->getItem()->getQty() == '') {
251:             return '';
252:         }
253:         return $this->getItem()->getQty() * 1;
254:     }
255: 
256:     /**
257:      * Check item is in stock
258:      *
259:      * @deprecated after 1.4.2.0-beta1
260:      * @return bool
261:      */
262:     public function getIsInStock()
263:     {
264:         if ($this->getItem()->getProduct()->isSaleable()) {
265:             if ($this->getItem()->getProduct()->getStockItem()->getQty() >= $this->getItem()->getQty()) {
266:                 return true;
267:             }
268:         }
269:         return false;
270:     }
271: 
272:     /**
273:      * Get checkout session
274:      *
275:      * @return Mage_Checkout_Model_Session
276:      */
277:     public function getCheckoutSession()
278:     {
279:         if (null === $this->_checkoutSession) {
280:             $this->_checkoutSession = Mage::getSingleton('checkout/session');
281:         }
282:         return $this->_checkoutSession;
283:     }
284: 
285:     /**
286:      * Retrieve item messages
287:      * Return array with keys
288:      *
289:      * text => the message text
290:      * type => type of a message
291:      *
292:      * @return array
293:      */
294:     public function getMessages()
295:     {
296:         $messages = array();
297:         $quoteItem = $this->getItem();
298: 
299:         // Add basic messages occuring during this page load
300:         $baseMessages = $quoteItem->getMessage(false);
301:         if ($baseMessages) {
302:             foreach ($baseMessages as $message) {
303:                 $messages[] = array(
304:                     'text' => $message,
305:                     'type' => $quoteItem->getHasError() ? 'error' : 'notice'
306:                 );
307:             }
308:         }
309: 
310:         // Add messages saved previously in checkout session
311:         $checkoutSession = $this->getCheckoutSession();
312:         if ($checkoutSession) {
313:             /* @var $collection Mage_Core_Model_Message_Collection */
314:             $collection = $checkoutSession->getQuoteItemMessages($quoteItem->getId(), true);
315:             if ($collection) {
316:                 $additionalMessages = $collection->getItems();
317:                 foreach ($additionalMessages as $message) {
318:                     /* @var $message Mage_Core_Model_Message_Abstract */
319:                     $messages[] = array(
320:                         'text' => $message->getCode(),
321:                         'type' => ($message->getType() == Mage_Core_Model_Message::ERROR) ? 'error' : 'notice'
322:                     );
323:                 }
324:             }
325:         }
326: 
327:         return $messages;
328:     }
329: 
330:     /**
331:      * Accept option value and return its formatted view
332:      *
333:      * @param mixed $optionValue
334:      * Method works well with these $optionValue format:
335:      *      1. String
336:      *      2. Indexed array e.g. array(val1, val2, ...)
337:      *      3. Associative array, containing additional option info, including option value, e.g.
338:      *          array
339:      *          (
340:      *              [label] => ...,
341:      *              [value] => ...,
342:      *              [print_value] => ...,
343:      *              [option_id] => ...,
344:      *              [option_type] => ...,
345:      *              [custom_view] =>...,
346:      *          )
347:      *
348:      * @return array
349:      */
350:     public function getFormatedOptionValue($optionValue)
351:     {
352:         /* @var $helper Mage_Catalog_Helper_Product_Configuration */
353:         $helper = Mage::helper('catalog/product_configuration');
354:         $params = array(
355:             'max_length' => 55,
356:             'cut_replacer' => ' <a href="#" class="dots" onclick="return false">...</a>'
357:         );
358:         return $helper->getFormattedOptionValue($optionValue, $params);
359:     }
360: 
361:     /**
362:      * Check whether Product is visible in site
363:      *
364:      * @return bool
365:      */
366:     public function isProductVisible()
367:     {
368:         return $this->getProduct()->isVisibleInSiteVisibility();
369:     }
370: 
371:     /**
372:      * Return product additional information block
373:      *
374:      * @return Mage_Core_Block_Abstract
375:      */
376:     public function getProductAdditionalInformationBlock()
377:     {
378:         return $this->getLayout()->getBlock('additional.product.info');
379:     }
380: 
381:     /**
382:      * Get html for MAP product enabled
383:      *
384:      * @param Mage_Sales_Model_Quote_Item $item
385:      * @return string
386:      */
387:     public function getMsrpHtml($item)
388:     {
389:         return $this->getLayout()->createBlock('catalog/product_price')
390:             ->setTemplate('catalog/product/price_msrp_item.phtml')
391:             ->setProduct($item->getProduct())
392:             ->toHtml();
393:     }
394: 
395:     /**
396:      * Set qty mode to be strict or not
397:      *
398:      * @param bool $strict
399:      * @return Mage_Checkout_Block_Cart_Item_Renderer
400:      */
401:     public function setQtyMode($strict)
402:     {
403:         $this->_strictQtyMode = $strict;
404:         return $this;
405:     }
406: 
407:     /**
408:      * Set ignore product URL rendering
409:      *
410:      * @param bool $ignore
411:      * @return Mage_Checkout_Block_Cart_Item_Renderer
412:      */
413:     public function setIgnoreProductUrl($ignore = true)
414:     {
415:         $this->_ignoreProductUrl = $ignore;
416:         return $this;
417:     }
418: }
419: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0