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 overview information 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Block_Multishipping_Overview 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( 00050 $this->__('Review Order - %s', $headBlock->getDefaultTitle()) 00051 ); 00052 } 00053 return parent::_prepareLayout(); 00054 } 00055 00056 public function getBillingAddress() 00057 { 00058 return $this->getCheckout()->getQuote()->getBillingAddress(); 00059 } 00060 00061 public function getPaymentHtml() 00062 { 00063 return $this->getChildHtml('payment_info'); 00064 } 00065 00066 public function getPayment() 00067 { 00068 return $this->getCheckout()->getQuote()->getPayment(); 00069 } 00070 00071 public function getShippingAddresses() 00072 { 00073 return $this->getCheckout()->getQuote()->getAllShippingAddresses(); 00074 } 00075 00076 public function getShippingAddressCount() 00077 { 00078 $count = $this->getData('shipping_address_count'); 00079 if (is_null($count)) { 00080 $count = count($this->getShippingAddresses()); 00081 $this->setData('shipping_address_count', $count); 00082 } 00083 return $count; 00084 } 00085 00086 public function getShippingAddressRate($address) 00087 { 00088 if ($rate = $address->getShippingRateByCode($address->getShippingMethod())) { 00089 return $rate; 00090 } 00091 return false; 00092 } 00093 00094 public function getShippingPriceInclTax($address) 00095 { 00096 $exclTax = $address->getShippingAmount(); 00097 $taxAmount = $address->getShippingTaxAmount(); 00098 return $this->formatPrice($exclTax + $taxAmount); 00099 } 00100 00101 public function getShippingPriceExclTax($address) 00102 { 00103 return $this->formatPrice($address->getShippingAmount()); 00104 } 00105 00106 public function formatPrice($price) 00107 { 00108 return $this->getQuote()->getStore()->formatPrice($price); 00109 } 00110 00111 public function getShippingAddressItems($address) 00112 { 00113 return $address->getAllVisibleItems(); 00114 } 00115 00116 public function getShippingAddressTotals($address) 00117 { 00118 $totals = $address->getTotals(); 00119 foreach ($totals as $total) { 00120 if ($total->getCode()=='grand_total') { 00121 if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_BILLING) { 00122 $total->setTitle($this->__('Total')); 00123 } 00124 else { 00125 $total->setTitle($this->__('Total for this address')); 00126 } 00127 } 00128 } 00129 return $totals; 00130 } 00131 00132 public function getTotal() 00133 { 00134 return $this->getCheckout()->getQuote()->getGrandTotal(); 00135 } 00136 00137 public function getAddressesEditUrl() 00138 { 00139 return $this->getUrl('*/*/backtoaddresses'); 00140 } 00141 00142 public function getEditShippingAddressUrl($address) 00143 { 00144 return $this->getUrl('*/multishipping_address/editShipping', array('id'=>$address->getCustomerAddressId())); 00145 } 00146 00147 public function getEditBillingAddressUrl($address) 00148 { 00149 return $this->getUrl('*/multishipping_address/editBilling', array('id'=>$address->getCustomerAddressId())); 00150 } 00151 00152 public function getEditShippingUrl() 00153 { 00154 return $this->getUrl('*/*/backtoshipping'); 00155 } 00156 00157 public function getPostActionUrl() 00158 { 00159 return $this->getUrl('*/*/overviewPost'); 00160 } 00161 00162 public function getEditBillingUrl() 00163 { 00164 return $this->getUrl('*/*/backtobilling'); 00165 } 00166 00167 public function getBackUrl() 00168 { 00169 return $this->getUrl('*/*/backtobilling'); 00170 } 00171 00172 /** 00173 * Retrieve virtual product edit url 00174 * 00175 * @return string 00176 */ 00177 public function getVirtualProductEditUrl() 00178 { 00179 return $this->getUrl('*/cart'); 00180 } 00181 00182 /** 00183 * Retrieve virtual product collection array 00184 * 00185 * @return array 00186 */ 00187 public function getVirtualItems() 00188 { 00189 $items = array(); 00190 foreach ($this->getBillingAddress()->getItemsCollection() as $_item) { 00191 if ($_item->isDeleted()) { 00192 continue; 00193 } 00194 if ($_item->getProduct()->getIsVirtual() && !$_item->getParentItemId()) { 00195 $items[] = $_item; 00196 } 00197 } 00198 return $items; 00199 } 00200 00201 /** 00202 * Retrieve quote 00203 * 00204 * @return Mage_Sales_Model_Qoute 00205 */ 00206 public function getQuote() 00207 { 00208 return $this->getCheckout()->getQuote(); 00209 } 00210 00211 public function getBillinAddressTotals() 00212 { 00213 $_address = $this->getQuote()->getBillingAddress(); 00214 return $this->getShippingAddressTotals($_address); 00215 } 00216 00217 00218 public function renderTotals($totals) 00219 { 00220 $colspan = $this->helper('tax')->displayCartBothPrices() ? 5 : 3; 00221 return $this->getChild('totals')->setTotals($totals)->renderTotals(-1, $colspan); 00222 } 00223 }