Magento Order Status Adjustment Module

At Creatuity we’re passionate about the innovation that open source projects like Magento make possible. We’re excited to share the following article about our new open source module, Magento Order Status Adjust, from Tomasz Szmyt, one of our development team leads and Magento 2 developers. Here’s the details in Tomasz’s own words:

Order Status flow in Magento 2

While working on one of our projects, I spotted quite a big inefficiency.

We have been heavily changing how order statuses are working. In that particular project, order statuses are split into two different flows:

  • orders that are meant to be picked up at stores (example status in flow: Ready for Pickup)

  • orders that are meant to be home delivered (example status in flow: Payment Authorized).

While this division sounds logical from the business perspective, for out of the box Adobe Commerce it is not possible. Adobe Commerce was not designed to set different status based on what is in the order.

All we can do in an out of the box Magento 2 installation is to set default status for each order state. It was obviously not sufficient for our client’s needs.

Solution created for our Client

We managed to craft a solution that was a proof of concept of the module which we are talking about now: it plugins into the Order Status setting process, intercepts Order data and based on what is in the order - adjusts the order status to the one we want.

It was an amazing experience to see how small parts of code can influence order flow to meet a client’s needs.

Example:

  • if order state is set as completed

    • if the order was picked up in the store

      • set status to “Picked in Store”

    • if an order was shipped to the customer

      • set status to “Delivered”

One thing that bugged me here was - there was no flexibility.

Flexibility Problems

The solution we prepared for our client was working correctly. I have to say even more: it has been working correctly for a couple of months now.

But I started to ask myself - “what if a client wants to change something”?

Theoretically - adding new rules is quite simple, but requires the ability to code. We don’t really want to write or adjust existing code for small changes. Furthermore - our client is on the Adobe Commerce Cloud platform. It is not (easily) possible to change even a small part of the code on the live site directly (without deployment) on Adobe Commerce Cloud.

At this moment, an idea surfaced - what if we’ll create something that’ll work in a similar way to the above solution, but will give us flexibility?

Implementation Plan

I have sat down and decided to gather requirements for the module. We needed a certain set of criteria by which the order can be automatically moved to a specific status. I gathered all required order fields to have a functional module and started thinking about architecture.

Having experience from a previous solution that was crafted specifically for one of our clients, I managed to prepare an outline of the implementation plan.

Solution outlined as below:

  • It should be possible to create rules to adjust order status to a specific one

  • It should be possible to execute certain rules as the first (priority) ones

  • It should be possible to switch on/off each rule and to enable/disable whole module

From the implementation perspective, I decided to reuse what is possible from the Sales Rules module. It has a configurator for rules that is used in the core for coupon codes and cart price rules. What is even more important - it is widely used in the entire Magento 2 codebase and is already familiar to our clients.

Finally, the name for the module came to my mind: Creatuity - Order Status Adjust Module

Open Source

I discussed how we want to approach the world with the Order Status Adjust module. After discussion, we have agreed that it should be published as Open Source, available via GitHub and Packagist.

At Creatuity, we want to create solutions that’ll satisfy our clients and at the same time - will be exciting for us. A module for setting desired order status based on defined rules is something that’ll for sure help a number of store owners and companies out there.

Now - I am really happy that the Order Status Adjust module can be used freely and is waiting out there to be installed on Magento 2 and Adobe Commerce installations to help various businesses grow.

Order Status Adjust module is publicly available here:

How it works

You can create multiple rules which will try to match against order when it is saved. If configured criteria are met - order status will be adjusted to one set in the rule.

You can configure rules by going to the Admin Panel. Then open the “Stores” tab on the left-side menu. Then simply click on the “Order Status Adjust Rules”.

You’ll see a list of rules. Of course - after installation it will be empty. In my case - I created 3 rules that’ll cover scenarios that might be dangerous.

I created an example rule which will catch all orders that were just placed and their Grand Total is greater or equal to $1000.00. All such orders will be moved to “Suspected Fraud” status. State will be set automatically to one that is corresponding to status.

Creating rules instead of having programmatic hard coded behavior for order statuses is something that will allow Magento 2 developers and business owners to streamline the process of managing orders.

Now - you have endless possibilities of configuring your order flow, without needing to write a single line of code!

Possible additional features

While work on the core part of the module is finished, we at Creatuity are open to extending it with more functionalities.

I see potential extension points for module, for example:

  • Order history entry for each applied rule

  • Rule Start and End Datetime

  • Allow/Disallow further processing of rules if rule matched

  • Introduction of more order fields to be used in rules criteria

  • Easier way to plugin to streamline process of adding custom rules

I have to say that future extension possibilities of the Order Status Adjust module are endless. List of possible features outlined above is only the tip of the iceberg.

Summary

We identified a business case that could be solved via a reusable module.

We created a module which fulfills the missing part of order status flow management for all Magento 2 and Adobe Commerce installations.

We at Creatuity will keep working to improve our clients businesses and where possible - to share what we have created with the Magento community.

Previous
Previous

How to Use Personalization to Drive Ecommerce Sales

Next
Next

5 Ways to Improve Your Ecommerce Customer Service