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
In TC i use:
public override Price CalculatePrice(OrderLine orderLine, Currency currency, Order order)
public class CustomOrderLineCalculator : OrderLineCalculator
To calculate the price of a product when adding to the basket. Can this be done in Vendr similarly?
I'm using :
public override Price CalculateOrderLineUnitPrice(OrderReadOnly order, OrderLineReadOnly orderLine, Guid currencyId, TaxRate taxRate)
But as these are ReadOnly I cant effectively change the Price when it gets added to the basket.
The product has a Base Price, and then properties sent along with the product in the orderLine will be then calculated before adding it to the basket.
So for instance the product is 20sm in size @ 12.00 per 2m, I'd need to calculate that when adding to the basket for this particular product.
Is there any way of doing that in Vendr?
CalculateOrderLineUnitPrice is the correct newer method, but I'm not sure I understand what you mean that you can't change the price? Yes, Price objects are immutable, but the job of CalculateOrderLineUnitPrice is to return the calculated price so you can return your own instance of a Price object with a different value to have it override the Price.
return new Price(valueWithoutTax, taxAmount, currencyId);
Or, if you want it to automatically calculate the tax amount for you from the passed in tax rate
return Price.Calculate(valueWithoutTax, taxRate, currencyId);
Ah yes, sorry see what you mean. Sorry, it's been a long day.
Great stuff, I can calc the price given by properties.
I know the feeling well. Glad I could help never the less 👍
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted