我正在尝试为Magento构建一个获取发票号的模块。主要问题是我遇到致命错误:在第19行($ invoice creation line)上的非对象上调用成员函数getIncrementId()。我的职责是:
$invoice = $observer->getEvent()->getInvoice()->getIncrementId();
$last4 = substr($invoice, -4);
$shipment = $observer->getEvent()->getShipment();
$track = Mage::getModel('sales/order_shipment_track')
->setNumber($last4) //tracking number / awb number
->setCarrierCode('custom') //carrier code
->setTitle('Custom'); //carrier title
$shipment->addTrack($track);
答案 0 :(得分:0)
尝试用此
替换第一行代码$invoice = $observer->getEvent()->getOrder()->getIncrementId();
使用getInvoice()方法获取订单可能会返回null,这将为您提供第19行的错误。