I’m trying to have the customer’s phone number show under the customer account information section. I know the phone number belongs to the customer address section but I’m t
Oh, thanks I'll post now! (see comments under original post).
Simply use the following:
$this->getCustomer()->getPrimaryBillingAddress()->getTelephone();
The first part will give you all the details, which you could then explore with var_dump()
as per @paperids.
Careful if there is NO address set then this getPrimaryBillingAddress() return a non object.
$address = $this->getCustomer()->getPrimaryBillingAddress();
if ( $address ) echo $address->getTelephone();
Luis has mentioned before that if customer didn't setup his billing address you will get an error in return: Call to a member function in a non-object.
If you want to be ready for such situation you can put the code into following IF statement:
<?php if ($customerAddressId){ ?>
<?php $address=Mage::getModel('customer/address')->load($customerAddressId); ?>
<?php $this->getCustomer()->getPrimaryBillingAddress()->getTelephone();
} ?>
This answer should go to @Alex, but just for the sake of completion, I'm posting this as an answer:
Use:
$this->getCustomer()->getPrimaryBillingAddress()->getTelephone()