Add an unpaid invoice to Magento order

Sometimes you’d just like to add an unpaid invoice to Magento order without it being set to paid status (Cash on Delivery anyone?). Once again I found a tutorial on Inchoo which described the biggest part of generating an invoice programmatically for an order, but it was always set to paid status. Well, I found the solution:

It’s mostly the line $invoice->setState() which I changed. And I switched to offline capturing, all other options are documented.

I was calling this function from an event observer but you could also just load an order using:

Leave a Reply