I want to show all shipping addresses of a customer. I am getting customer_id only. I am using $customer->getAddress() but it's giving all addresses from customer_address_entity table according to that customer_id. But I want only shipping addresses from these addresses. How can I solve it..

  • Do you want to get default shipping address?
    – KKR
    Jul 26, 2019 at 6:40
  • no i want all shipping addresses saved by that customer and want to show those list of shipping addresses on frontend
    – user81911
    Jul 26, 2019 at 6:42
  • 1
    There is only 1 address stored as Default Shipping in Magento. you can not able to save one address as shipping address. There is no option to save multiple shipping address. You can use any address to shipping address while checkout but there is only one Default Shipping address. you can change it from your account and also from backend.
    – KKR
    Jul 26, 2019 at 6:55
  • Please follow this blog post: rakeshjesadiya.com/… or meetanshi.com/blog/… Thanks Mar 15, 2023 at 10:10

3 Answers 3


Please note that getAddresses will return an array of Magento\Customer\Api\Data\AddressInterface

If you need the default Shipping address you can call:

$shipingAddress = $customer->getDefaultShippingAddress(); 

You can get the customer shipping address by using customer Id from below code.

In your block file:

public function __construct(
        \Magento\Customer\Api\AccountManagementInterface $accountManagement,
) {
      $this->accountManagement = $accountManagement;

public function getDefaultShippingAddress($customerId)
        try {
            $address = $this->accountManagement->getDefaultBillingAddress($customerId);
        } catch (NoSuchEntityException $e) {
            return __('You have not set a default shipping address.');
        return $address;

In your template file:

$customerId = 1;

$shippingAddress = $block->getDefaultShippingAddress($customerId);
//echo "<pre>";print_r($shippingAddress->__toArray());

Not a good option but you can use it.

Get all the $customer->getAddress() of customer. Get all the Orders of Customer. From this orders fetch the shipping address ids. The collection of addresses of customer filter it using this ids.

You will get all the addresses used for shipping.

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.