im trying to make a VAT provider but i cant seem to figure out why i get the following error
code looks like this:
public class VatProvider1 : Dynamicweb.eCommerce.Orders.VatProvider
{
public override double FindVatPercent(double DefaultVatPercent, Product Product)
{
var cart = Dynamicweb.eCommerce.Common.Context.Cart;
if (cart == null) return DefaultVatPercent;
if (cart.CustomerCountryCode == null || cart.DeliveryCountryCode == null)
return base.FindVatPercent(DefaultVatPercent, Product);
if ((cart.CustomerCountryCode.ToLower() == "dk" || cart.DeliveryCountryCode.ToLower() == "dk"))
{
return base.FindVatPercent(DefaultVatPercent, Product);
}
try
{
if (Product.VatGroup.GroupName != null && Product.VatGroup.GroupName == "Kurser")
{
return base.FindVatPercent(DefaultVatPercent, Product);
}
}
catch(Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message);
System.Web.HttpContext.Current.Response.Write(ex.StackTrace);
}
return 0;
}
}
Im getting an 2Object Reference not set to an insance of an object." in this codeline
if (Product.VatGroup.GroupName != null && Product.VatGroup.GroupName == "Kurser")
Anyone have an idea as to why i get this error and possibly what i have to do instead