I want to change how the address within book.phtml is displayed on frontend. In detail it is this part of code:

<h4><?php echo $this->__('Default Billing Address') ?></h4> <address> <?php echo $this->getPrimaryBillingAddressHtml() ?>

source code shows this:

<address> John Doe<br/> Company<br /> Street Address<br /> State, Province Zip Code<br/> Country<br/> T: 59874953847983<br /> </address>

I would like to have something like this:

<address> <div class="tagContainer"> <span class="oddTag">John Doe<br/></span> <span class="evenTag">Company<br /></span> <span class="oddTag">Street Address<br /></span> <span class="evenTag">State, Province Zip Code<br/></span> <span class="oddTag">Country<br/></span> <span class="evenTag">T: 59874953847983<br /></span> </div> </address>

In which file can I change that?

1 Answer 1


Add below code in your .phtml file

1) get address ID of logged in Customer

$_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling());

2) load address by address ID

$BillingAddress = Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses);

3) Now get details

  <div class="tagContainer">
   <span class="oddTag"><?php echo $BillingAddress->getFirstname() ?>&nbsp;<?php echo $BillingAddress->getLastname();?><br/></span>
   <span class="evenTag"><?php echo $BillingAddress->getCompany() ?><br /></span>
   <span class="oddTag"><?php echo $BillingAddress->getStreet();?><br /></span>
   <span class="evenTag"><?php echo $BillingAddress->getPostcode() ?><br/></span>
   <span class="oddTag"><?php echo $BillingAddress->getCountry() ?><br/></span>
   <span class="evenTag"><?php echo $BillingAddress->getTelephone(); ?><br /></span>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.