Open giancarloap opened 10 years ago
I changed the invoice code for now. I replaced the invoice part, It worked for me like this:
$incrementId = $order->getIncrementId(); $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); 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);
//Or 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();
$invoiced++;
}
catch (Mage_Core_Exception $e) {
}
I had a look in the code. Actually what it does now is ship, mail and create pdf (it does not create the invoice). We have set the settings in backend related to "auto invoice" ...
Ok. I forgot to answer. It's been a while. The changes I made worked, and creates the invoice. If you want, you can add the code I made to the library to add the invoice creation, or fork to a version with invoice creation. I'm new on github, i dont know if closing the issue removes all the comments I made. I think it would be good if any person can see this code that I made in case someone has the same situation or necessity that I had(to create invoice too). Thanks a lot, this lib helped me. Now my company is starting to grow.
I have a question, do you accept donation? If so, how to proceed?
I can ship orders but i cannot create invoice. The same happens on both options, ship, mail and invoice;ship and involce(no email). I get that message.
"Sent 1 shipments of 1 requested. Cannot create all invoices."
I debugged and after this attribution, the if returns false, it doesn't invoice, and order doesn't get complete because it didn't invoice. $invoices = Mage::getResourceModel('sales/order_invoice_collection')->setOrderFilter($orderId)->load(); try { if ($invoices->getSize() > 0) {
I'm using magento ce 1.7.0.2. Is the module compatible? Any idea on what the problem is?