Magento: Setting Order State Without Invoices or Shipments
In Magento v1.6, you can modify the order status of an order without creating an invoice or shipment. This allows for more flexibility in managing your orders. Let’s explore how to achieve this.
Modifying the Checkmo Payment Method
To begin, navigate to the /app/code/core/Mage/Payment/etc/system.xml file on your test server. Be sure to never modify core files directly in a production environment.
In this file, look for the <checkmo> section and update the source_model for the order_status field as shown below:
<checkmo translate="label">
<fields>
<order_status translate="label">
<source_model>adminhtml/system_config_source_order_status_new</source_model>
Remove the "new" from the source_model attribute to select an order status that belongs to the processing state. This allows you to choose your custom order status for checkmo payments.
Understanding the Limitations
While this modification changes the order status upon creation, it creates a hybrid state. The orders technically remain in the new/pending state but are assigned a status from the processing state. This means they don’t fully transition to the processing state as expected.
The orders will appear in the processing state section of the admin interface, but they won’t be considered truly in that state from a technical perspective.
The Challenge: Switching Between Custom Order Statuses
Your goal is to switch an order between custom order statuses within the processing state easily. This requires all new orders, regardless of payment method (checkmo or credit card), to be in the same initial state upon creation.
Unfortunately, this modification doesn’t fully solve your issue because:
- It only affects checkmo orders.
- The orders still technically remain in the new/pending status, which creates inconsistencies.
Potential Solutions
There are a couple of approaches you could consider:
-
Modify the Core Payment Model (High Risk): You can directly modify the core payment model to set the order state upon creation. However, this involves deep changes and is highly discouraged for production sites due to potential compatibility issues with updates.
-
Create a Custom Extension (Recommended): Develop a custom extension that intercepts the order creation process. This allows you to override the default behavior without directly modifying core files. You can then set the desired order status upon creation using the
setState()method:
$order->setState($newStatus);
This approach ensures your changes remain intact during updates and provides a cleaner solution.
Conclusion
While it’s possible to modify the order state of an order without creating invoices or shipments in Magento v1.6, this doesn’t fully achieve the desired result of switching between custom statuses within the processing state easily.
I recommend exploring the second approachâcreating a custom extensionâto ensure your changes are safe and maintainable. This is a more sustainable solution for your long-term needs.
For further guidance on extending Magento, consider checking out our guide on best practices for developing Magento extensions.
Remember to always back up your data before making any modifications and test changes extensively in a staging environment.