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 * Multishipping checkout choose item addresses block 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Block_Multishipping_Addresses extends Mage_Sales_Block_Items_Abstract 00035 { 00036 /** 00037 * Retrieve 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')->__('Ship to Multiple Addresses') . ' - ' . $headBlock->getDefaultTitle()); 00050 } 00051 return parent::_prepareLayout(); 00052 } 00053 00054 public function getItems() 00055 { 00056 $items = $this->getCheckout()->getQuoteShippingAddressesItems(); 00057 $itemsFilter = new Varien_Filter_Object_Grid(); 00058 $itemsFilter->addFilter(new Varien_Filter_Sprintf('%d'), 'qty'); 00059 return $itemsFilter->filter($items); 00060 } 00061 00062 /** 00063 * Retrieve HTML for addresses dropdown 00064 * 00065 * @param $item 00066 * @return string 00067 */ 00068 public function getAddressesHtmlSelect($item, $index) 00069 { 00070 $select = $this->getLayout()->createBlock('core/html_select') 00071 ->setName('ship['.$index.']['.$item->getQuoteItemId().'][address]') 00072 ->setId('ship_'.$index.'_'.$item->getQuoteItemId().'_address') 00073 ->setValue($item->getCustomerAddressId()) 00074 ->setOptions($this->getAddressOptions()); 00075 00076 return $select->getHtml(); 00077 } 00078 00079 /** 00080 * Retrieve options for addresses dropdown 00081 * 00082 * @return array 00083 */ 00084 public function getAddressOptions() 00085 { 00086 $options = $this->getData('address_options'); 00087 if (is_null($options)) { 00088 $options = array(); 00089 foreach ($this->getCustomer()->getAddresses() as $address) { 00090 $options[] = array( 00091 'value'=>$address->getId(), 00092 'label'=>$address->format('oneline') 00093 ); 00094 } 00095 $this->setData('address_options', $options); 00096 } 00097 return $options; 00098 } 00099 00100 public function getCustomer() 00101 { 00102 return $this->getCheckout()->getCustomerSession()->getCustomer(); 00103 } 00104 00105 public function getItemUrl($item) 00106 { 00107 return $this->getUrl('catalog/product/view/id/'.$item->getProductId()); 00108 } 00109 00110 public function getItemDeleteUrl($item) 00111 { 00112 return $this->getUrl('*/*/removeItem', array('address'=>$item->getQuoteAddressId(), 'id'=>$item->getId())); 00113 } 00114 00115 public function getPostActionUrl() 00116 { 00117 return $this->getUrl('*/*/addressesPost'); 00118 } 00119 00120 public function getNewAddressUrl() 00121 { 00122 return Mage::getUrl('*/multishipping_address/newShipping'); 00123 } 00124 00125 public function getBackUrl() 00126 { 00127 return Mage::getUrl('*/cart/'); 00128 } 00129 00130 public function isContinueDisabled() 00131 { 00132 return !$this->getCheckout()->validateMinimumAmount(); 00133 } 00134 }