Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
If I remember correctly you should also override the GetDiscountedPrice as that is used in calculating the orderfrm values
How do you register your CustomLineItemCalculator . Is it registered for Commerce Manager also?
Hi,
I am working on Commerce 13.21.0. I am facing an issue where the cart total doesnt seem to be getting updated after overriding the LineItem calculator. I am overriding the CalculateExtendedPrice method of ILineItemCalculator to increase the extended price of a line item by $10 if a line item requires customization.
public class CustomLineItemCalculator : DefaultLineItemCalculator { public CustomLineItemCalculator(ITaxCalculator taxCalculator) : base(taxCalculator) { } protected override Money CalculateExtendedPrice(ILineItem lineItem, Currency currency) { var price = base.CalculateExtendedPrice(lineItem, currency); var option = lineItem.Properties[Constant.LineItem.TextOption] as string; var message = lineItem.Properties[Constant.LineItem.CustomizationText] as string; if (!string.IsNullOrWhiteSpace(option) && option == "Add custom text + $10" && !string.IsNullOrWhiteSpace(message)) { var baseAmount = price.Amount; price = new Money(baseAmount + 10, currency); } return price; } }
Above is the code, a straight forward override and I am also making sure that the CustomLineItemCalculator is registreted as the ILineItemCalulator implementation during initialization.
I can also see the extended price being computed properly in the DB:
But inspite of all this the cart total is still $170.