|Number of votes:||6|
We have been asked for quite something on how to extend OrderStatus and OrderShipmentStatus. The problem is, we can't, because they are two enums, and C#/.NET does not allow you to extend enums in any way.
However, that is going to change in Commerce 13. OrderStatus and OrderShipmentStatus are now classes, and you add new instances to the system. For example, if you want to add a new status of "InDispute", you can do like this in one of your initialization modules:
OrderStatus.RegisterStatus(new OrderStatus(128, "InDispute"));
It's important to have this code in both your CMS and Commerce Manager sites.
New statuses will be available for filter and search in Commerce Manager (of course, you can now set an order status to that new value)
You might notice that the new status is not "localized". If you want it to display nicer, just add a new translation to App_GlobalResources\SharedStrings.resx
<data name="OrderStatus_InDispute" xml:space="preserve"> <value>In Dispute</value> </data>
Note that, this is a breaking change. As OrderStatus and OrderShipmentStatus are no longer enums, they can no longer be used in bitwise operations. If you were using some bitwise operations for comparison, for example
status & OrderStatus.InProgress == status
You would have to change it to
status == OrderStatus.InProgress
Commerce 13 is a few weeks away.