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: * Nominal total rendered
29: *
30: * Each item is rendered as separate total with its details
31: */
32: class Mage_Checkout_Block_Total_Nominal extends Mage_Checkout_Block_Total_Default
33: {
34: /**
35: * Custom template
36: *
37: * @var string
38: */
39: protected $_template = 'checkout/total/nominal.phtml';
40:
41: /**
42: * Getter for a quote item name
43: *
44: * @param Mage_Sales_Model_Quote_Item_Abstract $quoteItem
45: * @return string
46: */
47: public function getItemName(Mage_Sales_Model_Quote_Item_Abstract $quoteItem)
48: {
49: return $quoteItem->getName();
50: }
51:
52: /**
53: * Getter for a quote item row total
54: *
55: * @param Mage_Sales_Model_Quote_Item_Abstract $quoteItem
56: * @return float
57: */
58: public function getItemRowTotal(Mage_Sales_Model_Quote_Item_Abstract $quoteItem)
59: {
60: return $quoteItem->getNominalRowTotal();
61: }
62:
63: /**
64: * Getter for nominal total item details
65: *
66: * @param Mage_Sales_Model_Quote_Item_Abstract $quoteItem
67: * @return array
68: */
69: public function getTotalItemDetails(Mage_Sales_Model_Quote_Item_Abstract $quoteItem)
70: {
71: return $quoteItem->getNominalTotalDetails();
72: }
73:
74: /**
75: * Getter for details row label
76: *
77: * @param Varien_Object $row
78: * @return string
79: */
80: public function getItemDetailsRowLabel(Varien_Object $row)
81: {
82: return $row->getLabel();
83: }
84:
85: /**
86: * Getter for details row amount
87: *
88: * @param Varien_Object $row
89: * @return string
90: */
91: public function getItemDetailsRowAmount(Varien_Object $row)
92: {
93: return $row->getAmount();
94: }
95:
96: /**
97: * Getter for details row compounded state
98: *
99: * @param Varien_Object $row
100: * @return bool
101: */
102: public function getItemDetailsRowIsCompounded(Varien_Object $row)
103: {
104: return $row->getIsCompounded();
105: }
106:
107: /**
108: * Format an amount without container
109: *
110: * @param float $amount
111: * @return string
112: */
113: public function formatPrice($amount)
114: {
115: return $this->_store->formatPrice($amount, false);
116: }
117:
118: /**
119: * Import total data into the block, if there are items
120: *
121: * @return string
122: */
123: protected function _toHtml()
124: {
125: $total = $this->getTotal();
126: $items = $total->getItems();
127: if ($items) {
128: foreach ($total->getData() as $key => $value) {
129: $this->setData("total_{$key}", $value);
130: }
131: return parent::_toHtml();
132: }
133: return '';
134: }
135: }
136: