I try to generate invoices programmatically in Magento 1.9.4. It works so far with this code:
$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); // $invoice->register(); $transaction = Mage::getModel('core/resource_transaction') ->addObject($invoice) ->addObject($invoice->getOrder()); $transaction->save();
As you can see, I commented out $invoice->register() as it produces an error while executed (at least, with a specific payment option):
Can anyone explain, what $invoice->register() actually is for?
submitted by /u/nordcomputer
[link] [comments]