Class VatProvider
- Namespace
- Dynamicweb.Ecommerce.Orders
- Assembly
- Dynamicweb.Ecommerce.dll
The VatProvider allows you to manipulate country VAT on a product in eCommerce using a class inherited from Dynamicweb.eCommerce.Orders.VatProvider.
public class VatProvider
- Inheritance
-
VatProvider
- Inherited Members
Examples
The following example demonstrates how to create a VAT on luxury products (a sign that the product is a luxury suite will be the presence of the 'LUX' word in MetaKeywords field).
using System;
using Dynamicweb.Ecommerce.Products;
namespace Dynamicweb.Ecommerce.Examples.Orders
{
class VatProviderSample : Dynamicweb.Ecommerce.Orders.VatProvider
{
public override Double FindVatPercent(Double defaultVatPercent, Product product)
{
return product.Meta.Keywords.IndexOf("LUX") > -1 ? 20 : defaultVatPercent;
}
}
}
Remarks
WARNING: Calling an instance of a cart inside FindVatPercent(double, Product) i.e. by accessing Dynamicweb.Ecommerce.Common.Context.Cart, can cause the cart to be calculated and in order to do that, vat providers are created and called. This will cause stack overflow exception or DBConcurrencyException and hence an application crash.
Methods
FindVatPercent(double, Product)
Finds the vat percent for the product that should replace standard one.
public virtual double FindVatPercent(double defaultVatPercent, Product product)
Parameters
Returns
- double
Vat percent for the specified product