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 * Onepage checkout block 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Block_Onepage extends Mage_Checkout_Block_Onepage_Abstract 00035 { 00036 public function getSteps() 00037 { 00038 $steps = array(); 00039 00040 if (!$this->isCustomerLoggedIn()) { 00041 $steps['login'] = $this->getCheckout()->getStepData('login'); 00042 } 00043 00044 $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review'); 00045 00046 foreach ($stepCodes as $step) { 00047 $steps[$step] = $this->getCheckout()->getStepData($step); 00048 } 00049 return $steps; 00050 } 00051 00052 public function getActiveStep() 00053 { 00054 return $this->isCustomerLoggedIn() ? 'billing' : 'login'; 00055 } 00056 00057 /* 00058 // ADDRESSES 00059 00060 public function getAddressesHtmlSelect($address, $type) 00061 { 00062 if ($this->isCustomerLoggedIn()) { 00063 $options = array(); 00064 foreach ($this->getCustomer()->getAddresses() as $a) { 00065 $options[] = array( 00066 'value'=>$a->getId(), 00067 'label'=>$a->getStreet(-1).', '.$a->getCity().', '.$a->getRegion().' '.$a->getPostcode(), 00068 ); 00069 } 00070 00071 $addressId = $address->getId(); 00072 if (empty($addressId)) { 00073 if ($type=='billing') { 00074 $address = $this->getCustomer()->getPrimaryBillingAddress(); 00075 } else { 00076 $address = $this->getCustomer()->getPrimaryShippingAddress(); 00077 } 00078 if ($address) { 00079 $addressId = $address->getId(); 00080 } 00081 } 00082 00083 $select = $this->getLayout()->createBlock('core/html_select') 00084 ->setName($type.'_address_id') 00085 ->setId($type.'-address-select') 00086 ->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"') 00087 ->setValue($addressId) 00088 ->setOptions($options); 00089 00090 $select->addOption('', 'New Address'); 00091 00092 return $select->getHtml(); 00093 } 00094 return ''; 00095 } 00096 00097 public function getCountryHtmlSelect($address, $type) 00098 { 00099 $select = $this->getLayout()->createBlock('core/html_select') 00100 ->setName($type.'[country_id]') 00101 ->setId($type.':country_id') 00102 ->setTitle(Mage::helper('checkout')->__('Country')) 00103 ->setClass('validate-select') 00104 ->setValue($address->getCountryId()) 00105 ->setOptions($this->getCountryCollection()->toOptionArray()); 00106 00107 if ($type==='shipping') { 00108 $select->setExtraParams('onchange="shipping.setSameAsBilling(false);"'); 00109 } 00110 00111 return $select->getHtml(); 00112 } 00113 00114 00115 public function getRegionHtmlSelect($address, $type) 00116 { 00117 $select = $this->getLayout()->createBlock('core/html_select') 00118 ->setName($type.'[region]') 00119 ->setId($type.':region') 00120 ->setTitle(Mage::helper('checkout')->__('State/Province')) 00121 ->setClass('required-entry validate-state') 00122 ->setValue($address->getRegionId()) 00123 ->setOptions($this->getRegionCollection()->toOptionArray()); 00124 00125 return $select->getHtml(); 00126 } 00127 00128 // LOGIN STEP 00129 00130 public function getMessages() 00131 { 00132 return Mage::getSingleton('customer/session')->getMessages(true); 00133 } 00134 00135 public function getLoginPostAction() 00136 { 00137 return Mage::getUrl('customer/account/loginPost', array('_secure'=>true)); 00138 } 00139 00140 public function getSuccessUrl() 00141 { 00142 return $this->getUrl('* /*');//////////// 00143 } 00144 00145 public function getErrorUrl() 00146 { 00147 return $this->getUrl('* /*');//////////// 00148 } 00149 00150 public function getMethod() 00151 { 00152 return $this->getQuote()->getCheckoutMethod(); 00153 } 00154 00155 public function getMethodData() 00156 { 00157 return $this->getCheckout()->getMethodData(); 00158 } 00159 00160 // BILLING STEP 00161 00162 public function getBillingAddress() { 00163 if (!$this->isCustomerLoggedIn()) { 00164 return $this->getQuote()->getBillingAddress(); 00165 } else { 00166 return Mage::getModel('sales/quote_address'); 00167 } 00168 } 00169 00170 // SHIPPING STEP 00171 00172 public function getShippingAddress() 00173 { 00174 if (!$this->isCustomerLoggedIn()) { 00175 return $this->getQuote()->getShippingAddress(); 00176 } else { 00177 return Mage::getModel('sales/quote_address'); 00178 } 00179 } 00180 00181 // PAYMENT STEP 00182 00183 public function getPayment() 00184 { 00185 $payment = $this->getQuote()->getPayment(); 00186 if (empty($payment)) { 00187 $payment = Mage::getModel('sales/quote_payment'); 00188 } else { 00189 $payment->setCcNumber(null)->setCcCid(null); 00190 } 00191 return $payment; 00192 } 00193 */ 00194 }