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 address matipulation controller 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Multishipping_AddressController extends Mage_Core_Controller_Front_Action 00035 { 00036 /** 00037 * Retrieve multishipping checkout model 00038 * 00039 * @return Mage_Checkout_Model_Type_Multishipping 00040 */ 00041 protected function _getCheckout() 00042 { 00043 return Mage::getSingleton('checkout/type_multishipping'); 00044 } 00045 00046 /** 00047 * Retrieve checkout state model 00048 * 00049 * @return Mage_Checkot_Model_Type_Multishipping_State 00050 */ 00051 protected function _getState() 00052 { 00053 return Mage::getSingleton('checkout/type_multishipping_state'); 00054 } 00055 00056 00057 /** 00058 * Create New Shipping address Form 00059 */ 00060 public function newShippingAction() 00061 { 00062 $this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES); 00063 $this->loadLayout(); 00064 $this->_initLayoutMessages('customer/session'); 00065 if ($addressForm = $this->getLayout()->getBlock('customer_address_edit')) { 00066 $addressForm->setTitle(Mage::helper('checkout')->__('Create Shipping Address')) 00067 ->setSuccessUrl(Mage::getUrl('*/*/shippingSaved')) 00068 ->setErrorUrl(Mage::getUrl('*/*/*')); 00069 00070 if ($headBlock = $this->getLayout()->getBlock('head')) { 00071 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); 00072 } 00073 00074 if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { 00075 $addressForm->setBackUrl(Mage::getUrl('*/multishipping/addresses')); 00076 } 00077 else { 00078 $addressForm->setBackUrl(Mage::getUrl('*/cart/')); 00079 } 00080 } 00081 $this->renderLayout(); 00082 } 00083 00084 public function shippingSavedAction() 00085 { 00086 /** 00087 * if we create first address we need reset emd init checkout 00088 */ 00089 if (count($this->_getCheckout()->getCustomer()->getAddresses()) == 1) { 00090 $this->_getCheckout()->reset(); 00091 } 00092 $this->_redirect('*/multishipping/'); 00093 } 00094 00095 public function editShippingAction() 00096 { 00097 $this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING); 00098 $this->loadLayout(); 00099 $this->_initLayoutMessages('customer/session'); 00100 if ($addressForm = $this->getLayout()->getBlock('customer_address_edit')) { 00101 $addressForm->setTitle(Mage::helper('checkout')->__('Edit Shipping Address')) 00102 ->setSuccessUrl(Mage::getUrl('*/*/editShippingPost', array('id'=>$this->getRequest()->getParam('id')))) 00103 ->setErrorUrl(Mage::getUrl('*/*/*')); 00104 00105 if ($headBlock = $this->getLayout()->getBlock('head')) { 00106 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); 00107 } 00108 00109 if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { 00110 $addressForm->setBackUrl(Mage::getUrl('*/multishipping/shipping')); 00111 } 00112 } 00113 $this->renderLayout(); 00114 } 00115 00116 public function editShippingPostAction() 00117 { 00118 if ($addressId = $this->getRequest()->getParam('id')) { 00119 Mage::getModel('checkout/type_multishipping') 00120 ->updateQuoteCustomerShippingAddress($addressId); 00121 } 00122 $this->_redirect('*/multishipping/shipping'); 00123 } 00124 00125 public function selectBillingAction() 00126 { 00127 $this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING); 00128 $this->loadLayout(); 00129 $this->_initLayoutMessages('customer/session'); 00130 $this->_initLayoutMessages('checkout/session'); 00131 $this->renderLayout(); 00132 } 00133 00134 public function newBillingAction() 00135 { 00136 $this->loadLayout(); 00137 $this->_initLayoutMessages('customer/session'); 00138 if ($addressForm = $this->getLayout()->getBlock('customer_address_edit')) { 00139 $addressForm->setTitle(Mage::helper('checkout')->__('Create Billing Address')) 00140 ->setSuccessUrl(Mage::getUrl('*/*/selectBilling')) 00141 ->setErrorUrl(Mage::getUrl('*/*/*')) 00142 ->setBackUrl(Mage::getUrl('*/*/selectBilling')); 00143 00144 if ($headBlock = $this->getLayout()->getBlock('head')) { 00145 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); 00146 } 00147 } 00148 $this->renderLayout(); 00149 } 00150 00151 public function editAddressAction() 00152 { 00153 $this->loadLayout(); 00154 $this->_initLayoutMessages('customer/session'); 00155 if ($addressForm = $this->getLayout()->getBlock('customer_address_edit')) { 00156 $addressForm->setTitle(Mage::helper('checkout')->__('Edit Address')) 00157 ->setSuccessUrl(Mage::getUrl('*/*/selectBilling')) 00158 ->setErrorUrl(Mage::getUrl('*/*/*', array('id'=>$this->getRequest()->getParam('id')))) 00159 ->setBackUrl(Mage::getUrl('*/*/selectBilling')); 00160 00161 if ($headBlock = $this->getLayout()->getBlock('head')) { 00162 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); 00163 } 00164 } 00165 $this->renderLayout(); 00166 } 00167 00168 public function editBillingAction() 00169 { 00170 $this->_getState()->setActiveStep( 00171 Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING 00172 ); 00173 $this->loadLayout(); 00174 $this->_initLayoutMessages('customer/session'); 00175 if ($addressForm = $this->getLayout()->getBlock('customer_address_edit')) { 00176 $addressForm->setTitle(Mage::helper('checkout')->__('Edit Billing Address')) 00177 ->setSuccessUrl(Mage::getUrl('*/*/saveBilling', array('id'=>$this->getRequest()->getParam('id')))) 00178 ->setErrorUrl(Mage::getUrl('*/*/*', array('id'=>$this->getRequest()->getParam('id')))) 00179 ->setBackUrl(Mage::getUrl('*/multishipping/overview')); 00180 if ($headBlock = $this->getLayout()->getBlock('head')) { 00181 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); 00182 } 00183 } 00184 $this->renderLayout(); 00185 } 00186 00187 public function setBillingAction() 00188 { 00189 if ($addressId = $this->getRequest()->getParam('id')) { 00190 Mage::getModel('checkout/type_multishipping') 00191 ->setQuoteCustomerBillingAddress($addressId); 00192 } 00193 $this->_redirect('*/multishipping/billing'); 00194 } 00195 00196 public function saveBillingAction() 00197 { 00198 if ($addressId = $this->getRequest()->getParam('id')) { 00199 Mage::getModel('checkout/type_multishipping') 00200 ->setQuoteCustomerBillingAddress($addressId); 00201 } 00202 $this->_redirect('*/multishipping/overview'); 00203 } 00204 }