Magento 2 : Add Order Status in system configuration

add order status

Today we are going to demonstrate how to add list of order statuses in system configuration in Magento 2. This can be useful when you don’t want to hard code order status in the code especially when you are adding multiple order status.

Add source model “Magento\Sales\Model\Config\Source\Order\Status” to get the list of order statuses.

The below code will show you the multi select box where you can select more than one order statuses

<field id="order_status_planned_to_ship" translate="label" type="multiselect" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
       <label>Order Statuses</label>
       <source_model>Magento\Sales\Model\Config\Source\Order\Status</source_model>
</field>

The below code will show you the select box where you can select one order status

<field id="order_status_planned_to_ship" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
       <label>Order Statuses</label>
       <source_model>Magento\Sales\Model\Config\Source\Order\Status</source_model>
</field>

That’s it, Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.

2 thoughts on “Magento 2 : Add Order Status in system configuration

  1. It crashes the config somehow without giving any error.
    when you set this in system.xml to set is as a admin config value.

    It keeps on loading the config and then browser asks whether to kill page or wait.

Leave a Reply

Your email address will not be published. Required fields are marked *