*/ class Mage_Checkout_Block_Onepage_Billing extends Mage_Checkout_Block_Onepage_Abstract { /** * Sales Qoute Billing Address instance * * @var Mage_Sales_Model_Quote_Address */ protected $_address; /** * Customer Taxvat Widget block * * @var Mage_Customer_Block_Widget_Taxvat */ protected $_taxvat; /** * Initialize billing address step * */ protected function _construct() { $this->getCheckout()->setStepData('billing', array( 'label' => Mage::helper('checkout')->__('Billing Information'), 'is_show' => $this->isShow() )); if ($this->isCustomerLoggedIn()) { $this->getCheckout()->setStepData('billing', 'allow', true); } parent::_construct(); } public function isUseBillingAddressForShipping() { if (($this->getQuote()->getIsVirtual()) || !$this->getQuote()->getShippingAddress()->getSameAsBilling()) { return false; } return true; } /** * Return country collection * * @return Mage_Directory_Model_Mysql4_Country_Collection */ public function getCountries() { return Mage::getResourceModel('directory/country_collection')->loadByStore(); } /** * Return checkout method * * @return string */ public function getMethod() { return $this->getQuote()->getCheckoutMethod(); } /** * Return Sales Quote Address model * * @return Mage_Sales_Model_Quote_Address */ public function getAddress() { if (is_null($this->_address)) { if ($this->isCustomerLoggedIn()) { $this->_address = $this->getQuote()->getBillingAddress(); if (!$this->_address->getFirstname()) { $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname()); } if (!$this->_address->getMiddlename()) { $this->_address->setMiddlename($this->getQuote()->getCustomer()->getMiddlename()); } if (!$this->_address->getLastname()) { $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname()); } } else { $this->_address = Mage::getModel('sales/quote_address'); } } return $this->_address; } /** * Return Customer Address First Name * If Sales Quote Address First Name is not defined - return Customer First Name * * @return string */ public function getFirstname() { $firstname = $this->getAddress()->getFirstname(); if (empty($firstname) && $this->getQuote()->getCustomer()) { return $this->getQuote()->getCustomer()->getFirstname(); } return $firstname; } /** * Return Customer Address Last Name * If Sales Quote Address Last Name is not defined - return Customer Last Name * * @return string */ public function getLastname() { $lastname = $this->getAddress()->getLastname(); if (empty($lastname) && $this->getQuote()->getCustomer()) { return $this->getQuote()->getCustomer()->getLastname(); } return $lastname; } /** * Return Customer Address Middle Name * If Sales Quote Address Middle Name is not defined - return Customer Middle Name * * @return string | NULL */ public function getMiddlename() { $middlename = $this->getAddress()->getMiddlename(); if (empty($middlename) && $this->getQuote()->getCustomer()) { return $this->getQuote()->getCustomer()->getMiddlename(); } return $middlename; } /** * Check is Quote items can ship to * * @return boolean */ public function canShip() { return !$this->getQuote()->isVirtual(); } public function getSaveUrl() { } /** * Get Customer Taxvat Widget block * * @return Mage_Customer_Block_Widget_Taxvat */ protected function _getTaxvat() { if (!$this->_taxvat) { $this->_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat'); } return $this->_taxvat; } /** * Check whether taxvat is enabled * * @return bool */ public function isTaxvatEnabled() { return $this->_getTaxvat()->isEnabled(); } public function getTaxvatHtml() { return $this->_getTaxvat() ->setTaxvat($this->getQuote()->getCustomerTaxvat()) ->setFieldIdFormat('billing:%s') ->setFieldNameFormat('billing[%s]') ->toHtml(); } }