Thats kind of a hard thing you want to archive there.
The problem is, after the shipping got created, the order calculates the order status new (some of this happens in Model_Order->_checkState() ) so regardless what you set in the after shipping save event, it gets overwritten.
The Question becomes, why it is important to not have the state complete after this.
A possible Solution would be, to have a different complete status, which you can make the default, so you always have to set the complete/complete separate.
But this maybe does not fit your needs.
Solution 1
Working with an existing invoice
To change an existing invoice status from paid
to pending
is actually quite simple despite all the complexity built around it.
To do this, pay no attention to the invoice status
but focus solely on the invoice state
. All you have to do is change the invoice state
to the new desired state and the status
gets updated as well.
Since the invoice has already been paid for, you probably want to reset the total_paid
and base_total_paid
fields of the particular order the invoice was for so you at some point later on mark it as paid.
This should do just that:
<?php
$incrementId = '100014637';
$invoiceModel = Mage::getModel('sales/order_invoice');
try {
$invoice = $invoiceModel->loadByIncrementId($incrementId);
$order = Mage::getModel('sales/order')->load((int)$invoice->getOrderId());
$order->setTotalPaid(0)
->setBaseTotalPaid(0)
->save();
$invoice->setState(1)
->save();
} catch (Exception $ex) {
var_dump($ex->getMessage()); die;
}
To later mark it as paid on shipping, all you need do is simply get the invoice and call the pay
method on it.
Solution 2
Working with a new invoice
In order to create a pending
invoice, the payment method you use for the order must allow you to do such.
For that you need to override the payment method model and add these membere:
protected $_canCapture = true; // sets state to open
protected $_canCapturePartial = true; // lets you invoice partially
For example if you want to do this for Check/money order or Cash On Delivery you need to override either app/code/core/Mage/Payment/Model/Method/Checkmo.php or app/code/core/Mage/Payment/Model/Method/Cashondelivery.php and add the above attribute.
After this when you create an invoice you will have an option near the save button to set the invoice status. To create a pending invoice select Not capture
as seen below.
If you want to mark it later as paid edit the invoice and between the buttons on to one called Capture
.
Since what you want to do is mark it as paid on shipping, all you need do is simply get the invoice and call the pay
method on it.
Hope it helps someone.
Best Answer
Open file app/code/core/Mage/Sales/etc/config.xml and find node. Inside this node, add following.
also check bellow links.
https://stackoverflow.com/questions/8141140/magento-can-an-order-be-set-to-the-processing-state-without-creating-an-invoice
http://www.hostknox.com/tutorials/magento/order-statuses
http://www.dckap.com/blog/magento-order-state/
I hope this will help you.