For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
-
mfreeze
- Commodore (COMO)

- Posts: 421
- Joined: Mon Jan 24, 2005 2:07 pm
- Location: Washington, NJ
-
Contact:
Post
by mfreeze » Tue May 11, 2010 3:58 pm
I have set up a Zone that contains all the states west of the Mississippi River.
What I need to do now is on one page checkout set a different warehouse (for shipping charge purposes) based upon whether the province in the shipping address matches any province in this zone.
I have done this for countries but never for provinces. Following is how I did the change based on country. How could I do the same thing based on province?
Code: Select all
protected ICollection<ShipRateQuote> CanadianQuoteForShipment(CommerceBuilder.Orders.BasketShipment shipment)
{
ICollection<ShipRateQuote> rateQuotes = new System.Collections.ObjectModel.Collection<ShipRateQuote>();
//GET ALL OF THE POSSIBLE SHIPMETHODS for CANADIAN ORIGIN
WarehouseCollection warehouses = WarehouseDataSource.LoadForCountry(shipment.Address.CountryCode);
if (warehouses.Count > 0 && shipment.Address.CountryCode == "CA")
{
shipment.WarehouseId = warehouses[0].WarehouseId;
shipment.Save();
}
-
s_ismail
- Commander (CMDR)

- Posts: 162
- Joined: Mon Nov 09, 2009 12:20 am
-
Contact:
Post
by s_ismail » Wed May 12, 2010 2:57 am
Give a try by this, hopefully it will work
Code: Select all
protected ICollection<ShipRateQuote> CanadianQuoteForShipment(CommerceBuilder.Orders.BasketShipment shipment)
{
ICollection<ShipRateQuote> rateQuotes = new System.Collections.ObjectModel.Collection<ShipRateQuote>();
//GET ALL OF THE POSSIBLE SHIPMETHODS for CANADIAN ORIGIN
WarehouseCollection warehouses = WarehouseDataSource.LoadForCountry(shipment.Address.CountryCode);
ProvinceCollection provinces = ProvinceDataSource.LoadForCountry("CA");
foreach (Province province in provinces)
{
if (shipment.Address.Province == province.Name)
{
shipment.WarehouseId = warehouses[0].WarehouseId;
shipment.Save();
break;
}
}
}
-
mazhar
- Master Yoda

- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Wed May 12, 2010 6:08 am
Well what about making certain shipping method available only to some certain warehouse through merchant admin. Then when products belonging to that warehouse will be purchased, shipping method for warehouse will be available for order.
-
mfreeze
- Commodore (COMO)

- Posts: 421
- Joined: Mon Jan 24, 2005 2:07 pm
- Location: Washington, NJ
-
Contact:
Post
by mfreeze » Wed May 12, 2010 10:46 am
That won't work for how the client wants to handle shipping. Here's the story and what she wants to do.
There are 2 partners in the business; one will handle shipping for all products sold East of the Mississippi, the other products sold West of the Mississippi.
They both sell all products and they don't want to duplicate them on the site.
They want 2 warehouses one for West and one for East. If the shipping address is West then it will ship from the West warehouse, if it is East it will ship from the East warehouse.
I know I can do this somewhat similar to the way I checked the shipping country by comparing the shipping address to the provinces in the zone I set up. Looking at commercebuilder.shipping, I see that there is a commercebuilder.shipping.province.shipzoneprovince but am not 100% sure how to pull in the provinces in the zone I set up and do the compare to the shipping address province.
My coding skills are enough to come up with the idea but not the entire functionality. I think this would also solve some of the issues with multiple warehouses that have been posted on the forums but, like I said, my coding skills aren't strong enough to pull it off.
If you could point me in a direction, I could probably figure the rest of it out.
-
mfreeze
- Commodore (COMO)

- Posts: 421
- Joined: Mon Jan 24, 2005 2:07 pm
- Location: Washington, NJ
-
Contact:
Post
by mfreeze » Thu May 13, 2010 10:33 am
Had to use one of my programmers but it's working. Here's the code.
Code: Select all
protected ICollection<ShipRateQuote> WestOfMSQuoteForShipment(CommerceBuilder.Orders.BasketShipment shipment)
{
ICollection<ShipRateQuote> rateQuotes = new System.Collections.ObjectModel.Collection<ShipRateQuote>();
//GET ALL OF THE POSSIBLE SHIPMETHODS for COLORADO ORIGIN
WarehouseCollection warehouses = WarehouseDataSource.LoadForCriteria("name='colorado'");
if (warehouses.Count > 0 && shipment.Address.ShipZones.FindAll(delegate(ShipZone oZone) { return oZone.Name.ToLowerInvariant == "west of mississippi"; }).Count > 0)
{
shipment.WarehouseId = warehouses[0].WarehouseId;
shipment.Save();
}