Skip to main content
General

How To Create A Custom Order State In Magento?

By |January 30, 2015 January 3rd, 2022No Comments

 

Magento upgrade services are essential if you own a Magento store. Upgrade to the latest version of Magento 2 and create seamless shopping experiences to your customers.

In Magento, defining an appropriate Order Status provides a clear idea for the operations team to understand the position of the order and take the necessary action. Magento has an Order State and Order Status that describes the current position of the order. The Default Order State and the corresponding statuses available in Magento are:

[table id=6 /]

Each Order State can be associated with different kinds of Order Statuses to provide a clear picture about the order. While Magento provides an option to customize the Order Status, the Order State still has the default options. In few occasions, retailers look out for a customized Order State so that there is no miscommunication across different verticals in the organization.

We are planning to add a new Order State called “Partially paid”.  Let’s have a look at the method to create a customized Order State in Magento.

Step-1:

First we need register the new module in Magento. To accomplish this, create a new xml file in this path.  app/etc/modules/Custom_Orderstate.xml


    
        
            
                true
                local
            
         
    

Step-2:

Next, we need to configure our module. The configuration files can be found in the “etc” folder inside our module directory. So let’s create the configuration xml file: app/code/local/Custom/Orderstate/etc/config.xml


  
    
      
        0.1.0
      
    
    
      
        
          
            Custom_Orderstate
          
          
            core_setup
          
        
        
          
            core_write
          
        
        
          
            core_read
          
        
      
    
      
        
          
            
          
        
        
          
            
            
              
            
          
        
      
    
   
 

Step-3:

Once the configuration is done, we need to create a SQL script file to insert our order state on the database tables (sales_order_status & sales_order_status_state).  Let’s create a new PHP file in the following folder:
app/code/local/Custom/Orderstate/sql/orderstate_setup/mysql4-install-0.1.0.php

getTable('sales/order_status');
    $statusStateTable = $installer->getTable('sales/order_status_state');

    // Insert statuses
    $installer->getConnection()->insertArray(
        $statusTable,
        array('status', 'label'),
        array(
            array(
                'status' => 'partial_paid', 
                'label' => 'Partial Paid'
            )
        )
    );

    // Insert states and mapping of statuses to states
    $installer->getConnection()->insertArray(
        $statusStateTable,
        array('status', 'state', 'is_default'),
            array(
                array(
                    'status' => 'partial_paid', 
                    'state' => 'partial_paid', 
                    'is_default' => 1
                )
            )
        );

Step-4:

The final step is to login your Magento admin side. You can see the newly created order state ‘Partial Paid’ under the System > Order Statuses path.

Magento Order State

With changing market dynamic retailers, look out for methods to improve the operational efficiency by providing an appropriate order state.  This will allow a clear flow of communication across different departments in the organization enabling retailers to avoid confusions and increase productivity.

Balasubramaniam

Author Balasubramaniam

Balasubramaniam, aka Bala, is a Certified Magento Developer Plus Senior Software Engineer and one of our gems in the Magento team. A quick learner, he owns the projects that he works in and ensures they are delivered on time. He is very good at analyzing/fixing bugs and Magento customizations.

More posts by Balasubramaniam

Discover What You’re Missing

Get the weekly email full of actionable ideas and insights you can use at work and home.