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_Adminhtml 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 * Adminhtml sales order create shipping method form block 00029 * 00030 * @category Mage 00031 * @package Mage_Adminhtml 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract 00035 { 00036 protected $_rates; 00037 00038 public function __construct() 00039 { 00040 parent::__construct(); 00041 $this->setId('sales_order_create_shipping_method_form'); 00042 } 00043 00044 /** 00045 * Retrieve quote shipping address model 00046 * 00047 * @return Mage_Sales_Model_Quote_Address 00048 */ 00049 public function getAddress() 00050 { 00051 return $this->getQuote()->getShippingAddress(); 00052 } 00053 00054 /** 00055 * Retrieve array of shipping rates groups 00056 * 00057 * @return array 00058 */ 00059 public function getShippingRates() 00060 { 00061 if (empty($this->_rates)) { 00062 $groups = $this->getAddress()->getGroupedAllShippingRates(); 00063 /* 00064 if (!empty($groups)) { 00065 00066 $ratesFilter = new Varien_Filter_Object_Grid(); 00067 $ratesFilter->addFilter($this->getStore()->getPriceFilter(), 'price'); 00068 00069 foreach ($groups as $code => $groupItems) { 00070 $groups[$code] = $ratesFilter->filter($groupItems); 00071 } 00072 } 00073 */ 00074 return $this->_rates = $groups; 00075 } 00076 return $this->_rates; 00077 } 00078 00079 /** 00080 * Rertrieve carrier name from store configuration 00081 * 00082 * @param string $carrierCode 00083 * @return string 00084 */ 00085 public function getCarrierName($carrierCode) 00086 { 00087 if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $this->getStore()->getId())) { 00088 return $name; 00089 } 00090 return $carrierCode; 00091 } 00092 00093 /** 00094 * Retrieve current selected shipping method 00095 * 00096 * @return string 00097 */ 00098 public function getShippingMethod() 00099 { 00100 return $this->getAddress()->getShippingMethod(); 00101 } 00102 00103 /** 00104 * Check activity of method by code 00105 * 00106 * @param string $code 00107 * @return bool 00108 */ 00109 public function isMethodActive($code) 00110 { 00111 return $code===$this->getShippingMethod(); 00112 } 00113 00114 /** 00115 * Retrieve rate of active shipping method 00116 * 00117 * @return Mage_Sales_Model_Quote_Address_Rate || false 00118 */ 00119 public function getActiveMethodRate() 00120 { 00121 $rates = $this->getShippingRates(); 00122 if (is_array($rates)) { 00123 foreach ($rates as $group) { 00124 foreach ($group as $code => $rate) { 00125 if ($rate->getCode() == $this->getShippingMethod()) { 00126 return $rate; 00127 } 00128 } 00129 } 00130 } 00131 return false; 00132 } 00133 00134 public function getIsRateRequest() 00135 { 00136 return $this->getRequest()->getParam('collect_shipping_rates'); 00137 } 00138 00139 public function getShippingPrice($price, $flag) 00140 { 00141 return $this->getQuote()->getStore()->convertPrice(Mage::helper('tax')->getShippingPrice($price, $flag, $this->getAddress()), true); 00142 } 00143 }