n Magento, for most payment methods, you can assign an order status to a new order. You can do this in the system configuration for the specific payment method. But in a lot of cases, the only order status you can select here, is ‘Pending’.
But what if you want to assign a different order status to a new order? How can you increase the available order statuses in this dropdown? Well, it turns out that it’s very easy to accomplish this.
A simple solution
When you look at the system.xml
-file of Magento’s default payment module, you’ll see that for the dropdown of each payment method a source model is used. The Bank Transfer payment method for example uses the source model adminhtml/system_config_source_order_status_new
. So if we want to change the payment methods available in the dropdown, we have to assign a different source model. Lucky for us, Magento has a default source model with all order statuses, called adminhtml/system_config_source_order_status
. So all we have to do is create our own module, with a simple system.xml
-file that only overrides this configuration setting:
<?xml version="1.0"?>
<config>
<sections>
<payment>
<groups>
<banktransfer>
<fields>
<order_status>
<!-- Changing the source model allows all order statuses to be selected for this payment method: -->
<source_model>adminhtml/system_config_source_order_status</source_model>
</order_status>
</fields>
</banktransfer>
</groups>
</payment>
</sections>
</config>
And that’s it! Now the Bank Transfer payment method can have any order status for new orders. Sometimes it’s really that easy.
This is ideal for cases where you have to set the status of a new order to ‘Complete’ or any other status.
Hope this will help you.Thanks