Add new order status magento

To add a new order status in Magento, you can follow these steps:

Method 1: Using the Magento Admin Interface

  1. Log in to your Magento admin interface.
  2. Go to System > Configuration > Sales > Orders.
  3. Click on the Order Statuses tab.
  4. Click on the Add New Status button.
  5. Fill in the required information:
    • Status Name: Enter a name for the new order status (e.g., "Processing").
    • Status Code: Enter a unique code for the new order status (e.g., "processing").
    • Is Default: Select No if you don't want this status to be the default status.
    • Visible on Frontend: Select Yes if you want this status to be visible to customers on the frontend.
  6. Click Save to save the new order status.

Method 2: Using the Magento CLI

  1. Open a terminal or command prompt and navigate to your Magento root directory.
  2. Run the following command to add a new order status:
    php bin/magento config:set sales/order/statuses <new_status_name> <new_status_code>

    Replace <new_status_name> with the name of the new order status (e.g., "Processing") and <new_status_code> with the unique code for the new order status (e.g., "processing").

For example:

php bin/magento config:set sales/order/statuses Processing processing
  1. Run the following command to refresh the Magento configuration:
    php bin/magento cache:clean

    Method 3: Using a custom module

If you want to add a new order status programmatically, you can create a custom module and add the following code to the etc/config.xml file:

<?xml version="1.0"?>
<config>
    <modules>
        <YourModule>
            <version>1.0.0</version>
        </YourModule>
    </modules>
    <global>
        <sales>
            <order_status>
                <statuses>
                    <processing translate="label">
                        <label>Processing</label>
                        <code>processing</code>
                    </processing>
                </statuses>
            </order_status>
        </sales>
    </global>
</config>

Replace YourModule with the name of your custom module.

Then, run the following command to deploy the module:

php bin/magento module:deploy YourModule

Finally, run the following command to refresh the Magento configuration:

php bin/magento cache:clean

After adding the new order status, you can use it in your Magento store by selecting it from the order status dropdown menu in the admin interface or by using the setStatus method in your custom code.