【发布时间】:2014-10-16 07:07:06
【问题描述】:
理想情况下,如果订单上的任何物品没有创建发票,我们希望防止它们被运送。
目前,即使没有为订单创建发票,Magento (1.7.0.2) 也允许创建发货。我意识到这是为希望先发货然后开票的网站所有者设计的,但我们的工作流程要求在创建发票时先付款,然后再允许发货。
任何人都可以就如何更改提供任何代码明智的建议吗?我认为正确的文件是/app/code/local/Mage/Sales/Model/Order/Shipment.php,我们需要更改的代码如下,但我不确定如何单独检查每个项目的发票。
编辑 - 下面的代码可以正常工作吗?
protected function _beforeSave()
{
if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) {
Mage::throwException(
Mage::helper('sales')->__('Cannot create an empty shipment.')
);
}
$order = $this->getOrder();
if ($order->canInvoice()) {
Mage::throwException(
Mage::helper('sales')->__('Cannot ship items without an Invoice.')
);
}
【问题讨论】:
标签: magento