cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

What do you recommend to customize promotion action in Hybris?

Former Member
0 Likes
2,437

I have a case like that.

In all cart total promotions, we look at the cart total which is included taxes to apply, but in the action, discounts should be made over the tax-free prices(net price).

For example:

Cart total with taxes: 150 GBP

Cart total without taxes: 120 GBP

Promotion:

condition: cart total >=140 GBP

action: 10% discount over the cart total without taxes

Promotion applies since cart total with taxes is 150 (>=140)

Discount amount: 120/10 = 12 (over the tax-free price)

Result cart total is 138(150-12).

How to customize the promotion action according to the needs?

(Hybris v6.7 and new promotion engine)

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member1320010
Participant
0 Likes
  1. Update the CartRao or AbstractOrderRao with a new attribute as totalWithoutTax

  2. Create your own RuleCartSubTotalWithOutTaxConditionTranslator where you will the new attribute you created in CartRao eg:- de.hybris.platform.ruledefinitions.conditions.RuleCartTotalConditionTranslator

  3. Use the below impex and here you see your translator is referred (refer impex available in ruleengineservice)

INSERT_UPDATE RuleConditionDefinition;id[unique=true];name[lang=de];name[lang=en];priority;breadcrumb[lang=de];breadcrumb[lang=en];allowsChildren;translatorId;translatorParameters;categories(id)

INSERT_UPDATE RuleConditionDefinitionRuleTypeMapping;definition(id)[unique=true];ruleType(code)[default=PromotionSourceRule][unique=true]

INSERT_UPDATE RuleConditionDefinitionParameter;definition(id)[unique=true];id[unique=true];priority;name[lang=de];name[lang=en];description[lang=de];description[lang=en];type;value;required[default=true];validators

Former Member
0 Likes

Hi Suhaim, I already have a custom translator for promotion condition which has a custom attribute totalPriceWithTaxes but in the promotion action, I have to take net price into account to calculate discount amount since I need to calculate the discount amount over the net price. Therefore, my problem is already here. How customization should I do for the needs? On cart calculation level or on the promotion engine level?

former_member1320010
Participant
0 Likes

Do you want to perform action on this ? then you can add this value as a new type for promotion engine results In that case 1. Create a new RAO or reuse existing ones <bean class="de.hybris.platform.ruleengineservices.rao.MyTotalRAO" extends="de.hybris.platform.ruleengineservices.rao.AbstractRuleActionRAO"><property name="total" type="java.lang.Double" /></bean> 2. Define action item type with a total attribute <itemtype code="RuleBasedTotalAction" jaloclass="de.jalo.RuleBasedTotalAction" extends="AbstractRuleBasedPromotionAction" autocreate="true" generate="true" abstract="false"> 3. add the below action stratergies

 <bean id="defaultTotalActionStrategy" parent="abstractRuleActionStrategy" class="de.DefaultTotalActionStrategy">
 <bean id="defaultTotalRAOAction" parent="abstractRuleExecutableSupport" class="de.ruleengineservices.rule.evaluation.actions.impl.TotalActionRAOAction" />
 <bean id="defaultTotalAction" class="de.hybris.platform.ruledefinitions.actions.DefaultRuleExecutableAction">
 <bean id="defaultTotalActionStrategiesMappingMergeDirective" depends-on="promotionActionStrategiesMapping" parent="mapMergeDirective">
 <bean id="defaultTotalActionStrategiesMergeDirective" depends-on="actionStrategies" parent="listMergeDirective">

  1. In your calculationservice you can iterate over the promotion result check instance of RuleBasedTotalAction get your total attribute and then set it to cart