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_Bundle
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_Bundle
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Bundle_Block_Checkout_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
35: {
36: /**
37: * Get bundled selections (slections-products collection)
38: *
39: * Returns array of options objects.
40: * Each option object will contain array of selections objects
41: *
42: * @return array
43: */
44: protected function _getBundleOptions($useCache = true)
45: {
46: return Mage::helper('bundle/catalog_product_configuration')->getBundleOptions($this->getItem());
47: }
48:
49: /**
50: * Obtain final price of selection in a bundle product
51: *
52: * @param Mage_Catalog_Model_Product $selectionProduct
53: * @return decimal
54: */
55: protected function _getSelectionFinalPrice($selectionProduct)
56: {
57: return Mage::helper('bundle/catalog_product_configuration')->getSelectionFinalPrice($this->getItem(), $selectionProduct);
58: }
59:
60: /**
61: * Get selection quantity
62: *
63: * @param int $selectionId
64: * @return decimal
65: */
66: protected function _getSelectionQty($selectionId)
67: {
68: return Mage::helper('bundle/catalog_product_configuration')->getSelectionQty($this->getProduct(), $selectionId);
69: }
70:
71: /**
72: * Overloaded method for getting list of bundle options
73: * Caches result in quote item, because it can be used in cart 'recent view' and on same page in cart checkout
74: *
75: * @return array
76: */
77: public function getOptionList()
78: {
79: return Mage::helper('bundle/catalog_product_configuration')->getOptions($this->getItem());
80: }
81:
82: /**
83: * Return cart backorder messages
84: *
85: * @return array
86: */
87: public function getMessages()
88: {
89: $messages = $this->getData('messages');
90: if (is_null($messages)) {
91: $messages = array();
92: }
93: $options = $this->getItem()->getQtyOptions();
94:
95: foreach ($options as $option) {
96: if ($option->getMessage()) {
97: $messages[] = array(
98: 'text' => $option->getMessage(),
99: 'type' => ($this->getItem()->getHasError()) ? 'error' : 'notice'
100: );
101: }
102: }
103:
104: return $messages;
105: }
106: }
107: