Dear Dynamicweb,
We have an issue where our custom ConfigurationProvider is not always hit in the application, but after recycle of the application pool the configuration provider is hit again.
It is an issue as shipping vat is not handled correct for reverse vat.
This is our code:
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Notifications.Standard.Application.BeforeDynamicwebStart)]
public class BeforeStartObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
Dynamicweb.Configuration.SystemConfiguration.Instance.AddProviderPriority(new CustomConfigurationProvider());
}
}
public class CustomConfigurationProvider : IConfigurationProvider
{
public bool TryGet(string key, out string value)
{
var pageview = Dynamicweb.Frontend.PageView.Current();
if (key.Equals("/Globalsettings/Ecom/Order/ShippingFee/IncludeVATOnShippingFee", System.StringComparison.InvariantCultureIgnoreCase))
{
if (Dynamicweb.Ecommerce.Common.Context.ReverseChargeForVatEnabled)
{
value = bool.FalseString;
return true;
}
else
{
value = bool.TrueString;
return true;
}
}
}
}
I hope that you can solve this?
Best regards,
Anders