I try to get customer infos on success.phtml. I try it as guest and as logged in user.
First of all I get an order object.
$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->load($orderId);
Or for debugging on a separate page, with an order ID:
$order = Mage::getModel('sales/order')->load('300000040');
Then I try to get the name:
echo $order->getCustomerName();
that gives me: Gast (guest in englisch). No matter if I am logged in or not.
Then I try to get the email:
$billingAdress = $order->getBillingAddress();
echo "!!".print_r($billingAdress, 1); //nothing! empty
$customerEmail = $billingAdress->getEmail(); //Fatal error: Call to a member function getEmail() on a non-object....
It seems like the order object is wrong, I can't get the total:
echo $order->getGrandTotal(); //empty
Magento Version 1.7.0.2
Does anyone see my mistake?