Dmitry Tysh

Hello,

I am trying to figure out how to get shipping rates including the price and MaxLimit (the data from ShippingRates table). I can get the shipping method data by using the ShippingMethodHelper.GetShippingMethod() method, but I can not figure out to get the child data from ShippingRates table. Please help.

Thank you,

Dmitry




Re: Commerce Server 2007 Commerce Server 2007 Shipping Options

Nihit Kaul - MSFT

Hi Dmitry,

You cannot get the ShippingRates from the runtime side - this information is pulled from the DB when the pipelines are run.

Instead you can use the Management APIs to get this info for e.g. the ShippingMethods property for all the active ShippingMethods in the system:

http://msdn.microsoft.com/library/default.asp url=/library/en-us/sdkmref/html/P_Microsoft_CommerceServer_Orders_ShippingMethodManager_ShippingMethods.asp

If you really need this data on the runtime site, you can cache it on application startup and use it since it will not typically change too often.

Thanks,

Nihit





Re: Commerce Server 2007 Commerce Server 2007 Shipping Options

VKUMAR - MSFT

What is the scenario Where do you want to get the ShippingRates. You can look at Microsoft.CommerceServer.Orders.ShippingMethod class. This has ability to return the shippingrates.





Re: Commerce Server 2007 Commerce Server 2007 Shipping Options

DTysh

I need to calculate and display shipping cost for various shipping methods (ground, next day and etc.). By using ShippingMethodHelper.GetShippingMethod() I can get the shipping method data i.e. name, id. But also I need to get the shipping rate so that i can calculate the shipping cost.

Thank you,

Dmitry






Re: Commerce Server 2007 Commerce Server 2007 Shipping Options

Joseph Johnson

Dmitry,

More specifically, are you trying to get shipping rates before or after the user has selected a shipping rate. If you're trying to get the shipping cost after the user has selected a shipping rate, that information is contained within your order, and you should be able to access it through a property on the basket.

If you're trying to project how much your customer would pay for each shipping rate before choosing to use one of the rates, then you'll need to write custom logic (running a pipeline for this sort of thing would probably be inappropriate, since you'll end up storing a bunch of temporary calculations which have no importance to the actual order in the marshaled data). Vinod and Nihit have suggested using the OrderManagementContext and caching the results, which is probably the best approach for this, athough you could also write some custom ADO.Net logic which pulls this information from your transactions configuration database. The only problem with this is that you'll need to maintain connection strings in your web.config, which makes deployment more complicated.






Re: Commerce Server 2007 Commerce Server 2007 Shipping Options

Colin Bowern

If you need to display exact cost based on the items in the basket you can create a custom pipeline which calls the shipping calculation pipeline components. The pseudo code:

ShippingMethod[] shippingMethods = ShippingMethodManager.GetShippingMethods()

foreach(ShippingMethod shippingMethod in shippingMethods)

{

foreach(LineItem lineItem in basket.LineItems)

{

lineItem.ShippingMethodId = shippingMethod.Id;

}

basket.RunPipeline("shippingRateCalculation")

shippingMethodCosts.Add(shippingMethod.Id, basket.shippingTotal)
}

Another option is if you are using quantity calculation to just write a custom stored procedure which queries the shippingrates tables and returns the price for a quantity of x for each shipping rate. We use quantity calculation at the moment, so I would probably go the route of a custom stored procedure into the database for performance reasons (.NET-COM-.NET just seems like a lot of extra work).

Cheers,
Colin