00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Checkout 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Mustishipping checkout shipping 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Block_Multishipping_Shipping extends Mage_Sales_Block_Items_Abstract 00035 { 00036 /** 00037 * Get multishipping checkout model 00038 * 00039 * @return Mage_Checkout_Model_Type_Multishipping 00040 */ 00041 public function getCheckout() 00042 { 00043 return Mage::getSingleton('checkout/type_multishipping'); 00044 } 00045 00046 protected function _prepareLayout() 00047 { 00048 if ($headBlock = $this->getLayout()->getBlock('head')) { 00049 $headBlock->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $headBlock->getDefaultTitle()); 00050 } 00051 return parent::_prepareLayout(); 00052 } 00053 00054 public function getAddresses() 00055 { 00056 return $this->getCheckout()->getQuote()->getAllShippingAddresses(); 00057 } 00058 00059 public function getAddressCount() 00060 { 00061 $count = $this->getData('address_count'); 00062 if (is_null($count)) { 00063 $count = count($this->getAddresses()); 00064 $this->setData('address_count', $count); 00065 } 00066 return $count; 00067 } 00068 00069 public function getAddressItems($address) 00070 { 00071 $items = array(); 00072 foreach ($address->getAllItems() as $item) { 00073 if ($item->getParentItemId()) { 00074 continue; 00075 } 00076 $item->setQuoteItem($this->getCheckout()->getQuote()->getItemById($item->getQuoteItemId())); 00077 $items[] = $item; 00078 } 00079 $itemsFilter = new Varien_Filter_Object_Grid(); 00080 $itemsFilter->addFilter(new Varien_Filter_Sprintf('%d'), 'qty'); 00081 return $itemsFilter->filter($items); 00082 } 00083 00084 public function getAddressShippingMethod($address) 00085 { 00086 return $address->getShippingMethod(); 00087 } 00088 00089 public function getShippingRates($address) 00090 { 00091 $groups = $address->getGroupedAllShippingRates(); 00092 return $groups; 00093 } 00094 00095 public function getCarrierName($carrierCode) 00096 { 00097 if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) { 00098 return $name; 00099 } 00100 return $carrierCode; 00101 } 00102 00103 public function getAddressEditUrl($address) 00104 { 00105 return $this->getUrl('*/multishipping_address/editShipping', array('id'=>$address->getCustomerAddressId())); 00106 } 00107 00108 public function getItemsEditUrl() 00109 { 00110 return $this->getUrl('*/*/backToAddresses'); 00111 } 00112 00113 public function getPostActionUrl() 00114 { 00115 return $this->getUrl('*/*/shippingPost'); 00116 } 00117 00118 public function getBackUrl() 00119 { 00120 return $this->getUrl('*/*/backtoaddresses'); 00121 } 00122 00123 public function getShippingPrice($address, $price, $flag) 00124 { 00125 return $address->getQuote()->getStore()->convertPrice($this->helper('tax')->getShippingPrice($price, $flag, $address), true); 00126 } 00127 }