0

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?

1 Answer 1

1

This

$order = Mage::getModel('sales/order')->load('300000040');

Should be

$order = Mage::getModel('sales/order')->loadByIncrementId('300000040');

Use load only when you have the table primary key.

3
  • One different question: Why I don't see all the attributes with his getter in docs.magentocommerce.com/Mage_Sales/… or in the abstract class? Like the $order->getBillingAddress()->getEmail();
    – nbar
    Nov 19, 2013 at 14:37
  • That's a totally different question. Please ask an other one. And make it clear. Give some examples of what you are trying, the expected result and the actual result.
    – Marius
    Nov 19, 2013 at 14:41
  • Yes it's offtopic but not big enough for a question. Nevermind.
    – nbar
    Nov 19, 2013 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.