Wednesday 17 April 2019

Applying promotions to Sitecore XC Composer fields

Sitecore's XC's promotions engine has many parts which either either enter or reject the item from the promotion. The parts are as follows:
Item: This is a list of sellable items to which the promotion can be applied.

Qualification: This is the rule(s) that, when true, allows a benefit to be applied
Benefit: This is the actual benefit such as "free delivery", "money off" etc etc that is applied to the item or cart.

 
One feature lacking in the promotions engine is the ability to qualify a whole list of products based purely on their composer fields. That is that a user might want to apply the promotion to all electronic types. Sure you could use the tags field for this but then you can't apply the benefit to only that item as shown in the screenshot below:





 
To get around this there are 2 things which are needed:
1 - Qualify products based purely on their composer templates
2 - Apply a benefit to these products only if they qualify.

Essentially the entire process can be broken down as such:
 
The Qualification simply creates an expression that matches the ViewProperty's raw value to the qualification token such as BaseColour=Black.

With this technique, you can apply promotions to a whole criteria of products which makes things a lot easier.

An example of a qualification / benefit combo is shown below:


which produces this:



As usual, the PoC code is provided at: https://github.com/brimfulofashar/Sitecore-XC-Composer-Promotions