IBM Support

How to apply promotions based on priority rather then promotion-group order *|* -7B511C81482106DE85257837005D2C8F- *|*

Question & Answer


Question

How to apply promotions based on priority rather then promotion-group order *|* -7B511C81482106DE85257837005D2C8F- *|*

Answer

Technote (FAQ)


Question

How to apply promotions based on priority rather then promotion-group order?

The client wants promotions to be applied strictly based on the priority as otherwise they may end up giving more discount amount. So the question is; can this default order be changed some how for example is there a configuration which can be changed so that promotions are applied based on priority and not promotion-group order?

Here is an example:
If you have 2 promotions in the system:
a) All orders over $20 gets $5 off. Priority for this promotion is 150
b) All products in category "A" gets 10% off. Priority for this promotion is 100
If you add an item (worth $50) from category "A". Now promotions are applied in order of "b" and then "a". So final amounts comes to $40 (For example: $50 - 10% = $45 $45 - $5 = $40)
However the business wants the promotions applied in order of a and then b (based on the priority). Per business the final amount should be $40.50 (For example: $50 - $5 = $45 $45 - 10% = $40.50)

Cause

Promotion groups serve the following two purposes:

1- All of the promotions within a group share a common set of promotion policies.

2- Promotion groups are one factor that determines the order in which the promotion engine evaluates promotions during the shopping flow to determine whether the promotion applies to the current shopping cart or order.
By default promotions are evaluated according to their promotion group in the following order:
Catalog-entry-level group
Order-level group
Shipping group


Answer

The out of the box promotions are evaluated according to the order of promotion groups and the priority value if they are within the same promotion group The order level promotion (a) will be evaluated/applied after product level promotions (b). If you only want to evaluate based on priority value and ignore the order of promotion groups.

You will need to override the comparePromotionPriority () method of the PromotionExecutionSequenceBuilder that is used with the PromotionEngine.

.

<PromotionExecutionSequenceBuilder

impl="com.ibm.commerce.marketing.promotion.runtime.StorePathSupportedGro

upFirstSequenceBuilder" />

.

/**

* Compares the priority of two promotions

*

* @param promo1

* The first promotion.

* @param promo2

* The second promotion.

* @param context

* The current promotion context

* @return >0 when promo1 has precedence over promo2 =0

promo1 and promo2

* have the same priority <0 promo2 takes

precedence over promo1

*/

protected int comparePromotionPriority(Promotion promo1

Promotion promo2 PromotionContext context)


[{"Business Unit":{"code":"BU055","label":"Cognitive Applications"},"Product":{"code":"SS73G6","label":"Sterling Total Payments for Financial Services"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
12 October 2021

UID

ibm10767201