• Magento

    Programmatically create invoice of an order in magento

    Programmatically create invoice of an order in magento and create partial invoice of an order For some time need to create invoice of  an order.I have write code for  how to create invoice of an order pragmatically here. First of   load an order by order id/order increment id, Check which items of  that order are available for create invoice. if ,invoice is not created then create invoice of those items #this code is suite if order does have any invoice $order=Mage::getModel('sales/order')->load($orderID); #checkout order capable to create invoice if($order->canInvoice() and $order->getIncrementId()) { $items = array(); foreach ($order->getAllItems() as $item) { $items[$item->getId()] = $item->getQtyOrdered(); } $invoiceId=Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(),$items,null,false,true); #capture the invoice Mage::getModel('sales/order_invoice_api')->capture($invoiceId);    …