Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ivanweiler/1abf3e208129e699f76f to your computer and use it in GitHub Desktop.
Save ivanweiler/1abf3e208129e699f76f to your computer and use it in GitHub Desktop.
Magento Checkout - fill address forms from Quote address (if possible) for guest customers
/**
* Mage_Checkout_Block_Onepage_Billing::getAddress() should be something like this
*
* Similar for Mage_Checkout_Block_Onepage_Shipping
*/
public function getAddress()
{
if (is_null($this->_address)) {
$this->_address = $this->getQuote()->getBillingAddress(); //always take address from quote
if ($this->isCustomerLoggedIn()) {
if(!$this->_address->getFirstname()) {
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
}
if(!$this->_address->getLastname()) {
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
}
}
}
return $this->_address;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment