The dedault installation of nopCommerce only comes with US and Canada States and Territories pre-configured. To set up nopcommerce in Australia we have to customise the source code version or add them manually from the admin dashboad after the installation or add it from SQL Server Management Studio interface. In this blog I am going to expalin how to alter source code version so that we can use it for multiple Australian nopcommerce installations.
Step 1.
In the source code version insert a new line just above the line 1132 (in nopCommerce version 2.65, that is above var countries = new List<Country>) to the file “InstallationService.cs” in folder “Libraries\Nop.Services\Installation” under “Nop.Services” project.
And add the following code:
// Australia
var cAustralia = new Country
{
Name = “Australia”,
AllowsBilling = true,
AllowsShipping = true,
TwoLetterIsoCode = “AU”,
ThreeLetterIsoCode = “AUS”,
NumericIsoCode = 36,
SubjectToVat = false,
DisplayOrder = 1,
Published = true
};
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Australian Capital Territory”,
Abbreviation = “ACT”,
Published = true,
DisplayOrder = 1,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “New South Walse”,
Abbreviation = “NSW”,
Published = true,
DisplayOrder = 2,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Northern Territory”,
Abbreviation = “NT”,
Published = true,
DisplayOrder = 3,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Queensland”,
Abbreviation = “QLD”,
Published = true,
DisplayOrder = 4,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “South Australia”,
Abbreviation = “SA”,
Published = true,
DisplayOrder = 5,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Tasmania”,
Abbreviation = “TAS”,
Published = true,
DisplayOrder = 6,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Victoria”,
Abbreviation = “VIC”,
Published = true,
DisplayOrder = 7,
});
cAustralia.StateProvinces.Add(new StateProvince()
{
Name = “Western Australia”,
Abbreviation = “WA”,
Published = true,
DisplayOrder = 8,
});
//—————–
Step 2.
Insert following line just above the line //other countries:
cAustralia,
//other countries
Step 3.
Comment the existing code for Australia
//new Country
//{
// Name = “Australia”,
// AllowsBilling = true,
// AllowsShipping = true,
// TwoLetterIsoCode = “AU”,
// ThreeLetterIsoCode = “AUS”,
// NumericIsoCode = 36,
// SubjectToVat = false,
// DisplayOrder = 100,
// Published = true
//},
Step 4.
Also change the function InstallLanguages() found in InstallationService.cs file located @ \Libraries\Nop.Services\Installation folder.
Original function
protected virtual void InstallLanguages()
{
var language = new Language
{
Name =“English”,
LanguageCulture =“en-US”,
UniqueSeoCode =“en”,
FlagImageFileName =“us.png”,
Published =true,
DisplayOrder = 1
};
_languageRepository.Insert(language);
}
Change to
protected virtual void InstallLanguages()
{
var language = new Language
{
Name =“English”,
LanguageCulture =“en-AU”,
UniqueSeoCode =“au”,
FlagImageFileName =“au.png”,
Published =true,
DisplayOrder = 1
};
_languageRepository.Insert(language);
}