on ‎2018 Dec 03 4:47 PM
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)
Request clarification before answering.
Update the CartRao or AbstractOrderRao with a new attribute as totalWithoutTax
Create your own RuleCartSubTotalWithOutTaxConditionTranslator where you will the new attribute you created in CartRao eg:- de.hybris.platform.ruledefinitions.conditions.RuleCartTotalConditionTranslator
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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">
In your calculationservice you can iterate over the promotion result check instance of RuleBasedTotalAction get your total attribute and then set it to cart
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.