HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/App_Code/Pux/Utils/EcommerceTools.cs
using CMS.Ecommerce;
using CMS.Globalization;
using CMS.Helpers;
using CMS.SiteProvider;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Pux
{
    public class EcommerceTools
    {
        public static double GetTax(string taxCode = "DPH", string countryCode = "CZK", double defaultTax = 21)
        {
            return CacheHelper.Cache<double>(() =>
            {
                CountryInfo country = CountryInfoProvider.GetCountryInfoByCode(countryCode);
                if (country != null)
                {
                    TaxClassInfo taxClass = TaxClassInfoProvider.GetTaxClassInfo(taxCode, SiteContext.CurrentSiteName);
                    if (taxClass != null)
                    {
                        TaxClassCountryInfo taxClassCountryInfo = TaxClassCountryInfoProvider.GetTaxClassCountryInfo(country.CountryID, taxClass.TaxClassID);
                        return taxClassCountryInfo.TaxValue;
                    }
                }

                return defaultTax;
            }, new CacheSettings(10, SiteContext.CurrentSiteName + ".Pux.EcommerceTools.GetTax." + taxCode + "." + countryCode + "." + defaultTax.ToString()));
        }
    }
}