Try our conversational search powered by Generative AI!

Quan Mai
Feb 27, 2019
  3982
(6 votes)

New feature in Commerce 13: Extendable OrderStatus and OrderShipmentStatus

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.

Feb 27, 2019

Comments

Vincent
Vincent Feb 27, 2019 09:29 PM

Very helpful feature. I always “complain” c# enum design when I moved from java to .net. :p

Menno Zeilstra
Menno Zeilstra Mar 10, 2022 04:32 PM

I added a Queued Status, and added the Localization to the sharedstrings, somehow the Status remains blank when opening the details  (clicking in the Id Column)

Please login to comment.
Latest blogs
Anonymous Tracking Across Devices with Optimizely ODP

An article by Lead Integration Developer, Daniel Copping In this article, I’ll describe how you can use the Optimizely Data Platform (ODP) to...

Daniel Copping | Apr 30, 2024 | Syndicated blog

Optimizely Forms - How to add extra data automatically into submission

Some words about Optimizely Forms Optimizely Forms is a built-in add-on by Optimizely development team that enables to create forms dynamically via...

Binh Nguyen Thi | Apr 29, 2024

Azure AI Language – Extractive Summarisation in Optimizely CMS

In this article, I demonstrate how extractive summarisation, provided by the Azure AI Language platform, can be leveraged to produce a set of summa...

Anil Patel | Apr 26, 2024 | Syndicated blog

Optimizely Unit Testing Using CmsContentScaffolding Package

Introduction Unit tests shouldn't be created just for business logic, but also for the content and rules defined for content creation (available...

MilosR | Apr 26, 2024