If you want to get the customer information at the success page for you to be able pass it in a tracking script or display it in a page. Simply, try the following code:

<?php
//load the order model from specific order id
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
if ($order->getData()){
 $getCustomerId = $order->getCustomerId();
 $customer = Mage::getModel('customer/customer')->load($getCustomerId); 
 //to find all the available elements
 var_dump($customer->getData());
}
?>

The above code is only applicable for registered users and not for guest. Instead, if you like to get the last name of the customer you can try the following code:

<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
//If customer has no customer id, they're a guest.
if($order->getCustomerId() == NULL){
 echo $order->getBillingAddress()->getLastname();
}
//else, it's a normal registered user
else {
 $getCustomerId = $order->getCustomerId();
 $customer = Mage::getModel('customer/customer')->load($getCustomerId);
 $customer->getDefaultBillingAddress()->getLastname(); 
}
?>

Categorized in: