Posted on 11/03/2014 15:28:09
Currently, the prices for orderlines are cached internally, but unfortunately, manipulating the VAT does not clear this cache since the orderline doesn't actually know about the VatProvider. What you need to do is clear the cached price to force recalculation, however, no such clear cached method exists currently. There is a hack you can use until I get the ClearCachedPrices added to the code. Basically, you can set the quantity equals to quantity, which clears the prices.
public override double FindVatPercent(double DefaultVatPercent, Product Product)
{
// Define countries for which VAT is 0.
var vatExcemptCountries = new List { "SomeCountry", "SomeOtherCountry" };
// Check VAT exception conditions.
var cart = Context.Cart;
if (cart != null && vatExcemptCountries.Contains(cart.CustomerCountry))
{
// Clear cached prices on OrderLines.
// HACK!
foreach (var ol in cart.OrderLines)
{
ol.Quantity = ol.Quantity;
}
// Return VAT percent of 0.
return 0.0;
}
// VAT exception conditions are not met,
// return double.NaN to indicate we are not handling VAT.
return double.NaN;
}
I hope to get the ClearCachedPrices methods into the next hotfix for 8.4 (8.4.0.9) later today.
- Jeppe