I got a chance to have a look at your requirement. You are already in the right direction. You just need to add following more updates after setting the ShipZoneId from admin order manager page.
Go to the "private ICriteria GetFilteredCriteria(OrderFilter filter, int maximumRows, int startRowIndex, string sortExpression, bool count)" method at CommerceBuilder/Orders/OrderRepository.cs, locate the following code:
Code: Select all
// BUILD THE WHERE CRITERIA
List<string> whereCriteria = new List<string>();
and replace with:
Code: Select all
int zoneId = filter.ShipZoneId;
if (zoneId > 0)
{
ShipZone shipZone = EntityLoader.Load<ShipZone>(zoneId);
if (shipZone != null)
{
// process country rule
if (shipZone.Countries.Count > 0)
{
string[] countryCodes = new string[shipZone.Countries.Count];
for (int i = 0; i < shipZone.Countries.Count; i++)
{
Country country = shipZone.Countries[i];
countryCodes[i] = country.Id;
}
if (shipZone.CountryRule == FilterRule.IncludeSelected)
criteria.Add(Restrictions.In("O.BillToCountryCode", countryCodes));
else if (shipZone.CountryRule == FilterRule.ExcludeSelected)
criteria.Add(Restrictions.Not(Restrictions.In("O.BillToCountryCode", countryCodes)));
}
// process province rule
if (shipZone.Provinces.Count > 0)
{
string[] provinceCodes = new string[shipZone.Provinces.Count];
for (int i = 0; i < shipZone.Provinces.Count; i++)
{
Province objProvince = shipZone.Provinces[i];
provinceCodes[i] = objProvince.ProvinceCode;
}
if (shipZone.ProvinceRule == FilterRule.IncludeSelected)
criteria.Add(Restrictions.In("O.BillToProvince", provinceCodes));
else if (shipZone.ProvinceRule == FilterRule.ExcludeSelected)
criteria.Add(Restrictions.Not(Restrictions.In("O.BillToProvince", provinceCodes)));
}
// process the include postal codes filter
if (!string.IsNullOrEmpty(shipZone.PostalCodeFilter))
{
string[] postalCodes = shipZone.PostalCodeFilter.Split(',');
criteria.Add(Restrictions.In("O.BillToPostalCode", postalCodes));
}
// process the exclude postal codes filter
if (!string.IsNullOrEmpty(shipZone.ExcludePostalCodeFilter))
{
string[] postalCodes = shipZone.ExcludePostalCodeFilter.Split(',');
criteria.Add(Restrictions.Not(Restrictions.In("O.BillToPostalCode", postalCodes)));
}
}
}
// BUILD THE WHERE CRITERIA
List<string> whereCriteria = new List<string>();
This should do the trick for you.