1

We need to add a Pending state to the order when the invoice is created.

This works good with all the payment methods, but not with Bank Transfer.

In my configuration I have the new order state when client wants to pay by Bank Transfer as Processing.

Now I need to add a Pending state when I create an invoice in the admin. How can I do that?

Why we need this?
We have diferent people reponsible for different tasks, shipping is working based on states. Ex. if the order is in Pending state, then the shipping department is shipping those items, because we have the payment.

I hope I've explained my self,

Please sugest a posible solution,

Thanks,

1

2 Answers 2

1

Hi I updated Giel Berkers solution for Magento 2.3.4

To work with Magento 2.3 series you must use the following app\code\Vendor\Module\etc\adminhtml\system.xml where the system.xml structure and the model was updated.

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
   <system>
      <section id="payment">
         <group id="banktransfer">
            <field id="order_status">
               <source_model>Magento\Sales\Model\ResourceModel\Order\Status\Collection</source_model>
            </field>
         </group>
      </section>
   </system>
</config>
-2

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

2
  • Thank you for your effort, but this is a copy of gielberkers.com/set-order-status-new-orders-magento I already did this, but it's not what I need. We need to be able to control it, I mean, when I see that the money is in the acount, I create an invoice and then the state changes
    – Artur Rain
    Sep 1, 2015 at 11:25
  • When posting something for an other source, please state the source.
    – Marius
    Sep 1, 2015 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.