Order lookup based on Zones

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
mbartens
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 107
Joined: Mon Mar 09, 2015 3:34 am

Order lookup based on Zones

Post by mbartens » Wed Mar 25, 2015 4:14 am

I need to be able to look up orders based on zones. I'd like to add a drop down of the zones to the order manager screen. I've seen the drop down on the Tax Report so I can generate that.

I think what I need to do to start is modify the OrderFilter class and add a ShipZoneId.
Should that be an int like this:

Code: Select all

            this.ShipZoneId = 0;
and

Code: Select all

        public int ShipZoneId { get; set; }

AFter that I'm looking the OrderRepository. That is where I'm stuck. It doesn't look like the ShipZoneId associated with the order/shipments is stored so how could I filter that?
May

rmaweb
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Fri Sep 10, 2010 9:41 am

Re: Order lookup based on Zones

Post by rmaweb » Wed Mar 25, 2015 4:48 am

Hello May,

What version of Ablecommerce are you using? So that I can come up with some code to help you.
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3

mbartens
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 107
Joined: Mon Mar 09, 2015 3:34 am

Re: Order lookup based on Zones

Post by mbartens » Wed Mar 25, 2015 6:08 am

I'm using GoldR9, thank you.
May

rmaweb
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Fri Sep 10, 2010 9:41 am

Re: Order lookup based on Zones

Post by rmaweb » Wed Mar 25, 2015 12:20 pm

Hello May

I will try to get something together this weekend for you.
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3

mbartens
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 107
Joined: Mon Mar 09, 2015 3:34 am

Re: Order lookup based on Zones

Post by mbartens » Thu Mar 26, 2015 2:48 am

Thank you I really appreciate it!
May

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: Order lookup based on Zones

Post by nadeem » Thu Mar 26, 2015 6:24 am

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.
Last edited by nadeem on Thu Mar 26, 2015 6:40 am, edited 1 time in total.

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: Order lookup based on Zones

Post by nadeem » Thu Mar 26, 2015 6:33 am

Don't forget to add following using statement at the top of the page.

Code: Select all

using CommerceBuilder.Shipping;
After

Code: Select all

using CommerceBuilder.Services;

mbartens
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 107
Joined: Mon Mar 09, 2015 3:34 am

Re: Order lookup based on Zones

Post by mbartens » Fri Mar 27, 2015 4:35 am

This is working out very well. Thank you so much for your help and quick response! :D
May

Post Reply