当我从第三方服务获得某个响应时,我正在尝试将“处理”订单标记为完成.我已经为此设置了所有设置,但唯一的问题是订单处于处理状态.
我正在生成发票(我不认为我需要这个,因为每个项目在Magento后端都标记为“已开发票”)和这样的货件:
$order = Mage::getModel('sales/order')... (etc) $shipment = $order->prepareShipment($quantities); $shipment->register(); $shipment->setOrder($order); $shipment->save(); $invoice = $order->prepareInvoice($quantities); $invoice->register(); $invoice->setOrder($order); $invoice->save();
这似乎并没有这样做 – 我从这段代码中得不到任何错误,但订单仍然是处理.在后端,我仍然可以看到订单顶部的“发货”按钮,每个项目都处于“已开票”状态.
任何提示将非常感谢.
你可以看看
this article(俄语).
原文链接:https://www.f2er.com/php/135770.html$order = $observer->getEvent()->getOrder(); if (!$order->getId()) { return false; } if (!$order->canInvoice()) { return false; } $savedQtys = array(); $invoice = Mage::getModel('sales/service_order',$order)->prepareInvoice($savedQtys); if (!$invoice->getTotalQty()) { return false; } $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE); $invoice->register(); $invoice->getOrder()->setCustomerNoteNotify(false); $invoice->getOrder()->setIsInProcess(true); $transactionSave = Mage::getModel('core/resource_transaction') ->addObject($invoice) ->addObject($invoice->getOrder()); $transactionSave->save();