After upgrade I am getting this warning:
'OrderContext.GetTaxes(Guid, string, string, IOrderAddress)' is obsolete:
'This method is no longer used. Use ITaxCalculator instead. Will remain at least until December 2019.'
ITaxCalculator exposes only two methods that aren't tagged as obsolete, GetSalesTax and GetShippingTax. None of them is doing what OrderContext.Current.GetTaxes did.
Anyone has idea how to use ITaxCalculator instead of old GetTaxes? Thanx
I don't know how you want to use the tax values.
But if you just want to get the raw tax value objects you can directly use the TaxManager.GetTaxes method, as it is still there. You will need to read the DataTable returned and map it to TaxValue objects. Also, be aware that this method does not cache those tax values, so you may need to implement that yourself.
For calculating the tax amount of products in a product listing response, I sometimes find this fix useful.
For calculating tax amounts of line items, I suggest you use the ITaxCalculator approach. This approach saves the calculated values on the line item objects (and updates when neccessary), which is quite nice.
What I practically want to do is to get rid of that Build Warning.Just thought if GetTaxes is getting out soon there is another on ITaxCalculator that replaced it. The warning message at least implied that. I know that TaxManager.GetTaxes is still there, but December 2019 is next month, right?
I believe only OrderContext.GetTaxes is marked for deprecation. I didn't see this on TaxManager.GetTaxes.
And given that the new ITaxCalculator implementation uses TaxManager under-the-hood, I believe it is safe to use that one for now. I mean, they need to replace it before they remove it, right.
Pardon, you are correct, only this is marked obsolete OrderContext.Current.GetTaxes.Thanks for the effort!
I think I can add a bit more context to the answer. The reason we obsoleted several methods in OrderContext was we made a review/refactor of the API. GetTaxes does not really belong there as OrderContext should really be about orders. In a larger scale the class itself will be obsoleted one day (or at least marked as internal) in favor of new abstraction APIs like IOrderRepository or IOrderSearchService
Thanks to all who answered.