I’m trying onepage checkout. When I'm exiting 2co payment page by clicking on Place order button I'm navigating back to my site and the URL looks like this.
https://www.example.com/index.php/checkout/onepage/
and I got an error on the page as shown below
Fatal error: Call to a member function getMethodInstance() on a non-object in /home/xxx/public_html/store/app/code/core/Mage/Payment/Model/Observer.php on line 46
I have no idea and PHP knowledge to fix it.
Could anyone help me?
Best Answer
Even with very little PHP knowledge, you can always diagnose issues thanks to Magento's error reporting mechanism.
This error indicates the exact file & line of code which are responsible for it, so take the following steps:
app/code/core/Mage/Payment/Model/
& openObserver.php
,The line of code in 1.7 reads as follows:
Now, the error message also tells you that the following code is what is causing the issue:
So after you read the line of code on line 46, you'll see that that method is applied to the
$order
object, this is defined just above line 46 (on line 44):Now, knowing PHP you'd know that if the event did not catch the order correctly, the error would have been thrown here, I.E. on line 44, but it wasn't which means that it was caught correctly.
THUS, you can establish that the issue is with your payment method, because
$order->getPayment()
is anon object
according to the error message.You're likely using a modified payment method of some sorts which needs to be diagnosed.