Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How can we subtract a custom discount coupon amount in orderline(When we add a product to the basket?
We are implementing custom discount coupons as the requirement for the discount is a built differently than the out of the box TeaCommerce gift coupons functionality.
We created Umbraco doc types and nodes to keep the codes and discount rules.
Now I’ve used CustomOrderLineCalculator to calculate the price to override the price with my custom discount coupon amount. But when i add a product to basket the CalculatePrice method receives a total amount as ‘0’ in the orderLine parameter.
I’ve used the below example code to override the orderLine price :
Is this the right way or any other way to implement this ?
I think the issue is that when using a custom OrderLineCalculator, it is the calculators job to calculate the ENTIRE price for the OrderLine and so there won't be an existing total for you to base your calculation on, it is the calculators job to work out the orderline price from nothing.
If you want to know what the default calculator would have calculated, you could try calling the base method to do it's calculation first and then base your value on that.
var basePrice = base.CalculatePrice(orderLine, currency, order);
// Do some calculation on basePrice
In terms of other approaches, there are multiple options:
1) Add discount codes as products with a negative price value
2) Use events to listen for an order line to be added a modify the price then
Hope this helps.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted