| 在 Magento 创建发票时,可以通过脚本来进行。下面的代码可以在模块或单独脚本中用于自动化创建发票的费用。
$order = Mage::getModel('sales/order')->loadByIncrementId('100000001');
try
{
if(!$order->canInvoice()){
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if(!$invoice->getTotalQty()){
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Alternatively you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
(责任编辑:最模板) |

织梦dedecms金融投资管理公
人气:2199
ecshop英文外贸高尔夫模板
人气:715
ecshop红酒模板|红酒程序源
人气:859
织梦dede机械设备公司企业
人气:3257
ecshop蓝色冰爽妆品模板
人气:611
ecshop仿万表网模板
人气:965