I have a Magento extension which is supposed to add a donation to PayPal order, but it's throwing an error in Model/Observer.php. It is when people are done with PayPal and are redirected back to my website. The URL when this error is shown is /paypal/express/placeOrder/. The error is Fatal error: Call to a member function getBaseDonation() on a non-object in [path]/Model/Observer.php on line 215
. Line 215 is inside the if (!$donation) {
public function addPaypalItem($observer)
{
$cart = $observer->getEvent()->getPaypalCart();
$quote = $cart->getSalesEntity();
$donation = $quote->getBaseDonation();
if (!$donation) {
$donation = $quote->getShippingAddress()->getBaseDonation() ? $quote->getShippingAddress()->getBaseDonation() : $quote->getBillingAddress()->getBaseDonation();
}
if ($donation > 0) {
$cart->addItem(
Mage::helper('donations')->__('Donation'),
1,
$donation
);
}
return $this;
}
How can I solve this non-object problem? Thank you!