Dynamicweb.eCommerce.Prices Namespace > PriceCalculated Class : GetCountryVAT Method |
class MyPage : System.Web.UI.Page { private Dynamicweb.eCommerce.Products.Product product; private void Page_Load(System.Object sender, System.EventArgs e) { product = (Dynamicweb.eCommerce.Products.Product)Session["Ecom.Backend.Product"]; } public OrderLine SetUnitPrice(OrderLine orderLine, double amount) { string originalPriceInDBSetting = Base.GetGs("/Globalsettings/Ecom/Price/PricesInDbIncludesVAT"); bool isPricesWithVat = Base.ChkBoolean(originalPriceInDBSetting); double systemVat = 0.0; double discountPrice = 0.0; if (isPricesWithVat) { discountPrice = product.Price.PriceWithVAT / 100 * amount; } else { discountPrice = product.Price.PriceWithoutVAT / 100 * amount; } if (double.TryParse(Base.GetGs("/Globalsettings/Ecom/Price/PricesInDbVAT"), out systemVat)) { discountPrice *= 1 + (systemVat / 100.0); } //Remove country VAT discountPrice /= 1 + (new Dynamicweb.eCommerce.Prices.PriceCalculated().GetCountryVAT() / 100.0); //Set unit price orderLine.SetUnitPrice(discountPrice); return orderLine; } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2