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: * Mustishipping checkout shipping
29: *
30: * @category Mage
31: * @package Mage_Checkout
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Checkout_Block_Multishipping_Shipping extends Mage_Sales_Block_Items_Abstract
35: {
36: /**
37: * Get multishipping checkout model
38: *
39: * @return Mage_Checkout_Model_Type_Multishipping
40: */
41: public function getCheckout()
42: {
43: return Mage::getSingleton('checkout/type_multishipping');
44: }
45:
46: protected function _prepareLayout()
47: {
48: if ($headBlock = $this->getLayout()->getBlock('head')) {
49: $headBlock->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $headBlock->getDefaultTitle());
50: }
51: return parent::_prepareLayout();
52: }
53:
54: public function getAddresses()
55: {
56: return $this->getCheckout()->getQuote()->getAllShippingAddresses();
57: }
58:
59: public function getAddressCount()
60: {
61: $count = $this->getData('address_count');
62: if (is_null($count)) {
63: $count = count($this->getAddresses());
64: $this->setData('address_count', $count);
65: }
66: return $count;
67: }
68:
69: public function getAddressItems($address)
70: {
71: $items = array();
72: foreach ($address->getAllItems() as $item) {
73: if ($item->getParentItemId()) {
74: continue;
75: }
76: $item->setQuoteItem($this->getCheckout()->getQuote()->getItemById($item->getQuoteItemId()));
77: $items[] = $item;
78: }
79: $itemsFilter = new Varien_Filter_Object_Grid();
80: $itemsFilter->addFilter(new Varien_Filter_Sprintf('%d'), 'qty');
81: return $itemsFilter->filter($items);
82: }
83:
84: public function getAddressShippingMethod($address)
85: {
86: return $address->getShippingMethod();
87: }
88:
89: public function getShippingRates($address)
90: {
91: $groups = $address->getGroupedAllShippingRates();
92: return $groups;
93: }
94:
95: public function getCarrierName($carrierCode)
96: {
97: if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) {
98: return $name;
99: }
100: return $carrierCode;
101: }
102:
103: public function getAddressEditUrl($address)
104: {
105: return $this->getUrl('*/multishipping_address/editShipping', array('id'=>$address->getCustomerAddressId()));
106: }
107:
108: public function getItemsEditUrl()
109: {
110: return $this->getUrl('*/*/backToAddresses');
111: }
112:
113: public function getPostActionUrl()
114: {
115: return $this->getUrl('*/*/shippingPost');
116: }
117:
118: public function getBackUrl()
119: {
120: return $this->getUrl('*/*/backtoaddresses');
121: }
122:
123: public function getShippingPrice($address, $price, $flag)
124: {
125: return $address->getQuote()->getStore()->convertPrice($this->helper('tax')->getShippingPrice($price, $flag, $address), true);
126: }
127: }
128: