Is there an abstraction API somewhere for getting the tax value a product, without having to add said product to a cart, configuring shipping address, and then use ITaxCalculator, and then deleting the cart again? Or should I roll my own?
I will need to roll my own, I just wondered if there is an interface or base class I should override somewhere to implement it "The EPiServer Way"...
No there is no builtin functionality for that. That's interesting - if you have flat tax rate across the market then yes you should not have to care about the shipping address.
A faster way to implement ILineItem (most importantly, to set the TaxCategoryId property), and IOrderAddress, then you can use ITaxCalculator directly without having to create a cart and then delete it.
I will get back later if I have time
By "getting the tax value", do you mean the values that are configured in Commerce Manager?
For example this one:
In that case you can do something like this:
var contentLink = _referenceConverter.GetContentLink(lineItem.Code);
var entryContent = _contentLoader.Get<EntryContentBase>(contentLink);
var taxCategoryId = (entryContent as IPricing)?.TaxCategoryId;
var taxDto = TaxManager.GetTax(taxCategoryId.Value);
var percentage = taxDto.TaxValue.FirstOrDefault().Percentage;
In this case I'm getting the only one that is configured in the example above, but you can input whatever you need in the FirstOrDefault argument.
If you need to actually calculate which tax rate is applicable given various parameters (like ITaxCalculator does), then I think Quan already answered. :D
I decided to skip most of my problems by upgrading my upgrade project to Commerce 12 :)
Thanks for your input!!