gre*_*dev 7 php magento magento-1.4
当我从第三方服务获得某个响应时,我正在尝试将"处理"订单标记为完成.我已为此设置了所有设置,但唯一的问题是订单处于处理状态.
我正在生成发票(我不认为我需要这个,因为每个项目在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();
Run Code Online (Sandbox Code Playgroud)
这似乎并没有这样做 - 我从这段代码中得不到任何错误,但订单仍然是处理.在后端,我仍然可以看到订单顶部的"发货"按钮,每个项目都处于"已开票"状态.
任何提示将非常感谢.
Max*_*Max 17
尝试
$order->setStateUnprotected('complete',
'complete',
'Order marked as complete automatically',
false);
Run Code Online (Sandbox Code Playgroud)
此方法在app/code/local/Mage/Sales/Model/Order.php(在v1.6.1中)
938: public function setStateUnprotected($state, $status = false, $comment = '', $isCustomerNotified = null)
Run Code Online (Sandbox Code Playgroud)
在Magento 1.7.0.0中,此方法已被删除.试试这个:
$order->setData('state', "complete");
$order->setStatus("complete");
$history = $order->addStatusHistoryComment('Order marked as complete automatically.', false);
$history->setIsCustomerNotified(false);
$order->save();
Run Code Online (Sandbox Code Playgroud)
你可以看看这篇文章(俄文).
这是文章中的代码:
$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();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20748 次 |
| 最近记录: |