AI OnAI Off
You need to register your CustomShippingTaxCalculator as the implementation of IShippingCalculator as well
For example, in one of your IConfigurableModule.ConfigureContainer
services.AddTransient<IShippingCalculator , CustomShippingTaxCalculator >();
It took me a while to finally have time, but here it is https://vimvq1987.com/register-your-custom-implementation-the-sure-way/
Hi,
As we wants to override the method of "CalculateShippingTax" it's unable to hit when we called.
Otherthan this methods are being called. For example "CalculateReturnSalesTax", "CalculateSalesTax".
But "CalculateShippingTax" method is not going to fire. Really wondering that why it's happening with this method only.
Here is my code snippet, Please let me know if anything I missed.
public class CustomShippingTaxCalculator : DefaultShippingCalculator
{
public CustomShippingTaxCalculator ()
: base(
ServiceLocator.Current.GetInstance<ILineItemCalculator>(),
ServiceLocator.Current.GetInstance<IReturnLineItemCalculator>(),
ServiceLocator.Current.GetInstance<ITaxCalculator>(),
ServiceLocator.Current.GetInstance<ServiceCollectionAccessor<IShippingPlugin>>(),
ServiceLocator.Current.GetInstance<ServiceCollectionAccessor<IShippingGateway>>()
)
{
protected override Money CalculateShippingTax(IShipment shipment, IMarket market, Currency currency)
{
var shippingTax = GetShippingGstAmount(shipment, market, currency);
return new Money(currency.Round(shippingTax), currency);
}
protected override Money CalculateSalesTax(IShipment shipment, IMarket market, Currency currency)
{
var shippingTax = GetShippingGstAmount(shipment, market, currency);
return new Money(currency.Round(shippingTax), currency);
}
}
}
Calling these methods using this code:
var _calc = ServiceLocator.Current.GetInstance<IShippingCalculator>();
var returnTax = _calc.GetReturnSalesTax(shipment, market, currency);
var salesTax = _calc.GetSalesTax(shipment, market, currency);
var shippTax = _shippingCalculator.GetShippingTax(shipment, market, currency);
Thank you!!