Possible solution
Here is how you retrieve the primary billing address object:
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); if ($customerAddressId){ $address = Mage::getModel('customer/address')->load($customerAddressId); }If you want the address in html format do this:
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); if ($customerAddressId){ $address = Mage::getModel('customer/address')->load($customerAddressId); $htmlAddress = $address->format('html') }if you want specific parts of the address just print it out and see how that part is called
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); if ($customerAddressId){ $address = Mage::getModel('customer/address')->load($customerAddressId); echo "for example if you want the street do this:"; print_r($address->getData());echo ""; }
$street = $address->getData('street');It works the same for the rest of the of the address attributes (firstname, lastname, phone, ...)
Thank you for all these post!
ReplyDeletePS: I also like the blog title :)
Gr8 post :) really saved me alot ov time
ReplyDeleteGood work! looking forward for more snippets
ReplyDeletei am create a module which will note the order address changes once admin make any change in the order address. Do you have any idea how to show the posted address data in valid address format('html').
ReplyDeleteis there some function by which i can pass the address posted data and it can return me the address in html format.