Try our conversational search powered by Generative AI!

Discount on EntryAmount

Vote:
 

Hi

We are working with Episerver 10.8.0 and have a problem with discount.

I am using a promotion: Spend at least X amount and receive a discount off total order value. So I can get 10% off if I spend more then X$

In my implementation of ILineItemCalculator I have:

 protected virtual Money CalculateExtendedPrice(ILineItem lineItem, Currency currency)
        {           
            var itemPrice = lineItem.PlacedPrice * lineItem.Quantity;
            var entryDiscount = lineItem.TryGetDiscountValue((ILineItemDiscountAmount x) => x.EntryAmount);
            var ordreDiscount = lineItem.TryGetDiscountValue((ILineItemDiscountAmount x) => x.OrderAmount);

            var num = (itemPrice - ordreDiscount - entryDiscount) * _priceHelper.GetFactor();
          

            return new Money((num < 0m) ? 0m : num, currency);
        }

When I run the code on a line item that cost 799 I get:

entryDiscount = -159.89

ordreDiscount = 79.9

When I only have discount on orders, I would expect to have: 

entryDiscount = 0

ordreDiscount = 79.9

My question is: What can set the entryDiscount?

Many thanks in advance

#192626
May 21, 2018 19:23
Vote:
 

 Are you using the builtin promotion,  or a custom one?  I am not 100% sure but i think your expectation is correct..  

#192627
May 21, 2018 19:44
Vote:
 

I am using a builtin promotion. I have try to find out why I am getting a entry discount but have not been able to find it. Do you have some ideas where I can look?

#192644
May 22, 2018 8:10
Vote:
 

Your expectation is correct, there should be no entryDiscount here.

I assume you checked all active promotions (in case combine promotions). Have you set entryDiscount somewhere else in your implementation?

/Viet Anh

#192645
May 22, 2018 9:06
Vote:
 

I only have one discount active.

We have made a opgrade from commerce 7.5 to 10.8, and opdatede the code to use the new promotion. Is there a way that I can check if we are runneing any old episerver promotion?

#192653
May 22, 2018 10:42
Vote:
 

No the old promotions can't be run in conjuction with new promotions. they are mutually excluded.

#192655
May 22, 2018 11:10
Vote:
 

Cast the ILineItem to LineItem and check the OrderGroupId and OrderFormId.

Then load the order group and on the right order form check IOrderForm.Promotions.

That should tell you all promotions that has been applied.

#192674
May 22, 2018 15:29
* 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.