1

I need to get the account details of a registered customer and use them in the invoice PDF. The customer belongs to customer group "testgroup". By using the order details I can get the customer group and check if the customer belongs to "testgroup".

How do I get the customer ID and the rest of the account details?

SPRBRN
  • 1,307
  • 6
  • 19
  • 33

2 Answers2

1

Given $order, I can get the email from the order like this:

$customer_email = $order->getCustomerEmail();

Then I can get the account details with the following code:

$customer = Mage::getModel("customer/customer"); 
$customer->setWebsiteId(Mage::app()->getWebsite()->getId()); 
$customer->loadByEmail($customer_email); 
echo $customer->getId(); 
echo $customer->getFirstName(); 
print_r($customer->getData());  

Credit: http://www.techdilate.com/code/magento-get-customer-details-by-email-id/

SPRBRN
  • 1,307
  • 6
  • 19
  • 33
0
$customer = Mage::getSingleton('customer/session')->getCustomer();
    $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
    $address = Mage::getModel('customer/address')->load($customerAddressId);
    $fullname = $customer->getName();
    $firstname = $customer->getFirstname();
    $lastname = $customer->getLastname();
    $email = $customer->getEmail();
    $taxvat = $customer->getTaxvat();
    $tele = $customer->getTelephone();
    $telephone = $address->getTelephone();
    $street = $address->getStreet();
    $City = $address->getCity();
    $region = $address->getRegion();
    $postcode = $address->getPostcode();
Shorabh
  • 1,508
  • 12
  • 18