public void CalculateTax(Cart cart) { // TODO: this doesn't take into account discounts decimal taxAmount = 0; if (cart.OrderInfo.TaxZoneGuid == Guid.Empty) { GeoCountry country = new GeoCountry(cart.OrderInfo.BillingCountry); GeoZone taxZone = GeoZone.GetByCode(country.Guid, cart.OrderInfo.BillingState); if (taxZone != null) { cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } if (cart.OrderInfo.TaxZoneGuid != Guid.Empty) { Collection <TaxRate> taxRates = TaxRate.GetTaxRates(this.SiteGuid, cart.OrderInfo.TaxZoneGuid); if (taxRates.Count > 0) { foreach (CartOffer offer in cart.CartOffers) { offer.Tax = 0; foreach (TaxRate taxRate in taxRates) { if (offer.TaxClassGuid == taxRate.TaxClassGuid) { offer.Tax += (taxRate.Rate * (offer.OfferPrice * offer.Quantity)); offer.Save(); taxAmount += offer.Tax; //break; } } } } } cart.TaxTotal = Math.Round(taxAmount, this.RoundingDecimalPlaces, this.RoundingMode); if (cart.TaxTotal < 0) { cart.TaxTotal = 0; } cart.Save(); }