How to Change Order Status Programmatically in Magento 2

Hello Magento Devs,

All orders have an order status that is associated with a stage in the order processing workflow.

In this tutorial we are going to see how we can change order status programatically instead of doing it manually.

Here are some default magento 2 order states which you can use in set Order State and Order Status:

States & StatusesValue
STATE_NEWnew
STATE_PENDING_PAYMENTpending_payment
STATE_PROCESSINGprocessing
STATE_COMPLETEcomplete
STATE_CLOSEDclosed
STATE_CANCELEDcanceled
STATE_HOLDEDholded
STATE_PAYMENT_REVIEWpayment_review
STATUS_FRAUD (Only Used for Order Status)fraud

That’s it.

You can read more about order status and states in magento 2 documantation page at Order Status.

If you need help with this solution, feel free to ask in the Comments section below.

I would be happy to solve your queries.