1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Checkout_Block_Multishipping_Overview extends Mage_Sales_Block_Items_Abstract
35: {
36: 37: 38:
39: protected function _construct()
40: {
41: parent::_construct();
42: $this->addItemRender(
43: $this->_getRowItemType('default'),
44: 'checkout/cart_item_renderer',
45: 'checkout/multishipping/overview/item.phtml'
46: );
47: }
48:
49: 50: 51: 52: 53:
54: public function getCheckout()
55: {
56: return Mage::getSingleton('checkout/type_multishipping');
57: }
58:
59: protected function _prepareLayout()
60: {
61: if ($headBlock = $this->getLayout()->getBlock('head')) {
62: $headBlock->setTitle(
63: $this->__('Review Order - %s', $headBlock->getDefaultTitle())
64: );
65: }
66: return parent::_prepareLayout();
67: }
68:
69: public function getBillingAddress()
70: {
71: return $this->getCheckout()->getQuote()->getBillingAddress();
72: }
73:
74: public function getPaymentHtml()
75: {
76: return $this->getChildHtml('payment_info');
77: }
78:
79: 80: 81: 82: 83:
84: public function getPayment()
85: {
86: if (!$this->hasData('payment')) {
87: $payment = new Varien_Object($this->getRequest()->getPost('payment'));
88: $this->setData('payment', $payment);
89: }
90: return $this->_getData('payment');
91:
92: }
93:
94: public function getShippingAddresses()
95: {
96: return $this->getCheckout()->getQuote()->getAllShippingAddresses();
97: }
98:
99: public function getShippingAddressCount()
100: {
101: $count = $this->getData('shipping_address_count');
102: if (is_null($count)) {
103: $count = count($this->getShippingAddresses());
104: $this->setData('shipping_address_count', $count);
105: }
106: return $count;
107: }
108:
109: public function getShippingAddressRate($address)
110: {
111: if ($rate = $address->getShippingRateByCode($address->getShippingMethod())) {
112: return $rate;
113: }
114: return false;
115: }
116:
117: public function getShippingPriceInclTax($address)
118: {
119: $exclTax = $address->getShippingAmount();
120: $taxAmount = $address->getShippingTaxAmount();
121: return $this->formatPrice($exclTax + $taxAmount);
122: }
123:
124: public function getShippingPriceExclTax($address)
125: {
126: return $this->formatPrice($address->getShippingAmount());
127: }
128:
129: public function formatPrice($price)
130: {
131: return $this->getQuote()->getStore()->formatPrice($price);
132: }
133:
134: public function getShippingAddressItems($address)
135: {
136: return $address->getAllVisibleItems();
137: }
138:
139: public function getShippingAddressTotals($address)
140: {
141: $totals = $address->getTotals();
142: foreach ($totals as $total) {
143: if ($total->getCode()=='grand_total') {
144: if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) {
145: $total->setTitle($this->__('Total'));
146: }
147: else {
148: $total->setTitle($this->__('Total for this address'));
149: }
150: }
151: }
152: return $totals;
153: }
154:
155: public function getTotal()
156: {
157: return $this->getCheckout()->getQuote()->getGrandTotal();
158: }
159:
160: public function getAddressesEditUrl()
161: {
162: return $this->getUrl('*/*/backtoaddresses');
163: }
164:
165: public function getEditShippingAddressUrl($address)
166: {
167: return $this->getUrl('*/multishipping_address/editShipping', array('id'=>$address->getCustomerAddressId()));
168: }
169:
170: public function getEditBillingAddressUrl($address)
171: {
172: return $this->getUrl('*/multishipping_address/editBilling', array('id'=>$address->getCustomerAddressId()));
173: }
174:
175: public function getEditShippingUrl()
176: {
177: return $this->getUrl('*/*/backtoshipping');
178: }
179:
180: public function getPostActionUrl()
181: {
182: return $this->getUrl('*/*/overviewPost');
183: }
184:
185: public function getEditBillingUrl()
186: {
187: return $this->getUrl('*/*/backtobilling');
188: }
189:
190: public function getBackUrl()
191: {
192: return $this->getUrl('*/*/backtobilling');
193: }
194:
195: 196: 197: 198: 199:
200: public function getVirtualProductEditUrl()
201: {
202: return $this->getUrl('*/cart');
203: }
204:
205: 206: 207: 208: 209:
210: public function getVirtualItems()
211: {
212: $items = array();
213: foreach ($this->getBillingAddress()->getItemsCollection() as $_item) {
214: if ($_item->isDeleted()) {
215: continue;
216: }
217: if ($_item->getProduct()->getIsVirtual() && !$_item->getParentItemId()) {
218: $items[] = $_item;
219: }
220: }
221: return $items;
222: }
223:
224: 225: 226: 227: 228:
229: public function getQuote()
230: {
231: return $this->getCheckout()->getQuote();
232: }
233:
234: public function getBillinAddressTotals()
235: {
236: $_address = $this->getQuote()->getBillingAddress();
237: return $this->getShippingAddressTotals($_address);
238: }
239:
240:
241: public function renderTotals($totals, $colspan=null)
242: {
243: if ($colspan === null) {
244: $colspan = $this->helper('tax')->displayCartBothPrices() ? 5 : 3;
245: }
246: $totals = $this->getChild('totals')->setTotals($totals)->renderTotals('', $colspan)
247: . $this->getChild('totals')->setTotals($totals)->renderTotals('footer', $colspan);
248: return $totals;
249: }
250:
251: 252: 253: 254: 255: 256: 257: 258:
259: public function addRowItemRender($type, $block, $template)
260: {
261: $type = $this->_getRowItemType($type);
262: parent::addItemRender($this->_getRowItemType($type), $block, $template);
263: return $this;
264: }
265:
266: 267: 268: 269: 270: 271:
272: public function getRowItemHtml(Varien_Object $item)
273: {
274: $type = $this->_getItemType($item);
275: $block = $this->_getRowItemRenderer($type)
276: ->setItem($item);
277: $this->_prepareItem($block);
278: return $block->toHtml();
279: }
280:
281: 282: 283: 284: 285: 286:
287: public function _getRowItemRenderer($type)
288: {
289: $type = $this->_getRowItemType($type);
290: $type = isset($this->_itemRenders[$type]) ? $type : $this->_getRowItemType('default');
291: return parent::getItemRenderer($type);
292: }
293:
294: 295: 296: 297: 298: 299:
300: protected function _getRowItemType($type)
301: {
302: return 'row_' . $type;
303: }
304: }
305: