Try our conversational search powered by Generative AI!

Promotions [Beta]: Different discount percent for each line item.


I have EPiServer.Commerce 9.19.0 installed (probably promotions are not Beta anymore). I have a requirement to be able to apply different percentage discount for each line item. Basically, I am storing discount % in line item metadata.

Now I created new EntryPromotion and entry promotion processor. In the evaluate method I am loading all line items which has discount % stored in metadata and want to apply those, but when creating RewardDescription there is no way to set discount on each line item - only one value for all line items:

protected override RewardDescription Evaluate(
    AdditionalItemDiscountPromoData promotionData,
    PromotionProcessorContext context)
    var orderForm = context.OrderForm;
    var cart = context.OrderGroup as Cart;
    if (cart == null)
        return NoReward(promotionData);
    var lineItems = cart.GetAllLineItems().Where(HasDiscount);
    var priceEntries = new List();
    foreach (var lineItem in lineItems)
        var discount = // <-- discount to apply to single item (decimal) ([constants.additionaldiscountpercentmetafield] ?? 0.0m); priceentries.add(new priceentry(lineitem)); } var discounttoallitems="10;" return rewarddescription.createpercentagereward( fulfillmentstatus.fulfilled, new[] { createredemptiondescription(new affectedentries(priceentries)) }, promotiondata, discounttoallitems,><-- only one discount value can be applied to all items but require separate for each item description: $"{promotiondata.discountpercent} % discount applied to line items"); }>

Is there some other way to apply such promotion?

Edited, Aug 01, 2016 9:43

Maybe doing them as separate redemptions is technically feasible and maybe even the logically correct way to handle it? Is there any condition to be met to qualify for the promotion or is that already determined elsewhere when the discount percentage is set on the line item? What determines the discount? Any chance it is more like a customer group specific price and should be handled as such instead of a promotion?

Aug 02, 2016 19:59

I have a special page for customer support staff where they can set discounts onto customer carts - for the whole cart and for separate items.

I made it to work by creating custom EntryPromotion where an editor can set discount percent on the promotion. So editor can create several promotions with predefined discount percents. On my support staff page, I allow choosing one of the defined promotion. The only disadvantage is that you have to create all possible promotion discount % upfront.

Aug 03, 2016 8:22

I am not sure i see the need for having a promotion for this at all.

Do they really add discounts on the carts and not on the purchase orders?

In either case, why can't customer support discounts be deducted directly from the prices?

My first try would be to change how the lineitem total is calculated

Unless you actually need some of the promotion functionality like priority or excluding other promotions?

Aug 07, 2016 20:39

Yes, there is such need. The use case is: Customer calls Support and asks some questions about the product. The customer might need the same product but with a different color, for example. Support staff gives a discount for the item because they do not have requested color.

Aug 08, 2016 8:39

IIRC that customer support scenario is supported in commerce manager for both old and new promotion system. I don't remember the details of the implementation but I think it should be possible to mimic if you want to handle it by other means than commerce manager.

Aug 08, 2016 15:25

Yes, CM supports both automatic and manually-set discounts, in both old and new promotion system. The order manager can simply edit the price of a lineitem to set the discount manually.

Aug 08, 2016 16:18

But the supported scenario is for orders not carts is it not?

Can you describe your scenario in more detail Maris?

Does customer support create the purchase order?

Are customers allowed to modify their carts after customer service have added the discount? What happens if they remove that lineitem and later add it again?

Aug 12, 2016 17:43

Erik, the scenario is for Carts and customer support do not create purchase orders. Also, support does not have access to Commerce Manger - they have access only to a specific page where they can do what I described. And customers can add more products if they want after support applied discounts and they can remove items with discounts then they will loose discount.

But this issue is fixed as described in my answer. :)

Aug 26, 2016 12:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.