0
我有一個Magento擴展,它應該向PayPal順序添加捐贈,但它在Model/Observer.php中引發錯誤。這是人們完成PayPal並被重定向回我的網站。顯示此錯誤時的URL爲/ paypal/express/placeOrder /。錯誤是Fatal error: Call to a member function getBaseDonation() on a non-object in [path]/Model/Observer.php on line 215
。 215行在if(!$ donation)內{Magento擴展錯誤:調用非對象上的成員函數
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;
}
如何解決這個非對象問題?謝謝!