I would like to get all customer shipping address to give shipping selection option in product view page itself.

I created a block to appear inside product view page. And I have below code snippet.

It gives all address including billing address.

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getSingleton('customer/session')->getCustomer();

    $address = Mage::getModel('customer/address')->load($customerData->getId());

    echo '<pre>'; print_r($address); echo '</pre>';

How to get only shipping address in magento?

  • $customer->getDefaultShippingAddress() or $customerAddressId = Mage::getSingleton(‘customer/session’)->getCustomer()->getDefaultShipping(); if ($customerAddressId){ $address = Mage::getModel(‘customer/address’)->load($customerAddressId); $address->getData(); }
    – Pawankumar
    Commented Mar 17, 2016 at 8:51

5 Answers 5


The customer won't always have a default shipping address saved, however if they do you can get it like so :

$addressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
if ($addressId){
    $address = Mage::getModel('customer/address')->load($addressId);

Your just missing the getDefaultShipping()


It's Working for me.

The address information is stored within the Mage_Customer_Model_Customer so you should be able to create an instance of it with the customer id.

$customer = Mage::getModel('customer/customer')->load($customerId);

Then depending on the type of address that you are looking for you should be able to call one of the following functions.

Primary Billing Address: $model->getPrimaryBillingAddress();

Primary Shipping Address: $model->getPrimaryShippingAddress();

General Address Selection: $model->getAddressItemById();

Happy Codding. :)

$addressesCollection = Mage::getResourceModel('customer/address_collection');
/* for particular address 
$addressesCollection->addFieldToFilter('id','12'); */

foreach ($addressesCollection as $address) {
  echo "<pre>"; 

Use below code:

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getSingleton('customer/session')->getCustomer();

  foreach ($customerData->getAddresses() as $address) {    
        echo $address->getId();

  • This will give all billing address also. i need only shipping address
    – Anto S
    Commented Mar 17, 2016 at 8:57

@invissible according to Magento, customer only have 1 billing and 1 shipping address as its default address, and all others addresses which is added by customer or admin is set as customer additional address.

As you stated How to get only shipping address in magento? in your question, my thought was you only have 1 shipping address only which you get using:

$customer = Mage::getModel('customer/customer')->load(104);

$default = $customer->getDefaultShipping();

and if you want to show all additional address you can get it using:

$additional = $customer->getAdditionalAddresses();

foreach($additional as $add){

Zend_Debug::dump($add->getData(), 'Additional');


Have a look and let me know if you have any query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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