November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If you can get throught to create a CultureInfo out of Commerce language, then you can request two letter region name:
var c = new CultureInfo("en-GB"); var r = new RegionInfo(c.LCID); string name = r.Name; string regionName = r.TwoLetterISORegionName; // gives you "GB"
Thanks Valdis for your suggestion, it would definitely work if I could link the country to the culture as the RegionInfo class is culture dependant. What I'd like to get is a direct correspondance between the ISO3 country code already built in as Code property in the Commerce Countries list with its ISO2 code. From what I've found so far from EPiServer's example for PayPal payment gateway their solution is to create a txt file that maps the ISO3/ISO2 codes and then add some code logic that retrieves one based on the other. Thanks anyway for your help.
There is no builtin feature to get the two letter code from a three letter code.
RegionInfo does not take a three letter code as input as it's rather a culture function than a country function.
What I've done is that I enumerate the full culture list (CultureInfo.GetCultures) and create a mapping dictionary in a singleton. See quick example below
var alpha3Regions = new Dictionary<string,RegionInfo>(); foreach (var culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { alpha3Regions.Add(region.ThreeLetterISORegionName, new RegionInfo(culture.LCID)); }
Next time I'll try compiling the code as well :D
var region = new
RegionInfo(culture.LCID);
alpha3Regions.Add(region.ThreeLetterISORegionName, region);
Hi all,
I'm wondering if there's a way to get the ISO2 code from the Commerce Countries list to pass to PayPal as part of its payment structure. As far as I can tell the Commerce Countries list contains only the Code property that is ISO3 country code: is there any way to get the corresponding ISO2 code? (ex. for United Kingdom country ISO3 is GBR while ISO2 is GB). Thanks in advance! Jennifer