Using Sitecore to Define Business Rules

When building out new functionality within Sitecore, I like to utilize the CMS to hold business rules as best it can.  This allows for a clear separation of code and business rules which allows the business to modify these as the business evolves without touching the code.  Let’s look at some examples.

Sale Statuses

On the GoCollette site, we display a list of tour dates on the tour detail page as well as the first page of the booking engine.  These dates can be tagged as either discounted (on sale) or sold out.  Sounds simple enough, but we took it one step further and gave the business (content author) the ability to decide which Sale Statuses are define “Sold Out” and “On Sale”.

We simply created a Tour Settings item and added a couple fields to define our selection. Our then iterates over the date objects and checks them against the settings item.  Below is a screenshot of the settings item we created.

salestatuses

Package Upgrade

We have a similar case for presenting a tour’s upgrades. An example of an upgrade would be traveling to Australia/New Zealand and extending the trip to include Fuji or even as simple as upgrading your hotel room. The scenario we faced though was more complex than Sale Statuses. For a room upgrade we could only show it when it met certain conditions, pre-extensions had their own conditions and the list goes on. There were about 7-8 of these.

Instead of writing all these conditions in code, we simply used the same Tour Settings Item from the previous example and allowed the business/content authors to define the rules. You can see from the screenshot below we are only allowing Pre-Extensions when the Layout Type (template) is either Optional, Default Optional or None. It also needs to have a Service Order (template) of either Pre or Extension. The code knows how to decipher the field values, and if it meets the criteria the Pre Extension will be shown on the site. We have several of these fields defining the other types of upgrades (Pre Extensions, Post Extensions, Room Upgrades ect…)

packageupgrade

In Conclusion

Once you start incorporating business rules and settings into Sitecore it really provides a good separation. Of course not all conditions should be built out like the examples above, but by using Sitecore they do make it easy if you wish to do so.

Enjoy and sorry I haven’t blogged in forever!
Tim

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s