Welcome to MSDN Blogs Sign in | Join | Help

Data Tools and Software Testing

Old model-based testers never die; they just transition to a higher state.

Syndication

News

    These postings are provided "AS IS" with no warranties, and confer no rights.
    Use of included script and code samples are subject to the terms specified here.

CS 2007: GetShippingMethods and GetShippingMethods(String)

Just wanted to highlight the key difference between these 2 APIs which can both be used to display the set of ShippingMethods which are enabled in the TransactionConfig (the site resource) database.

 

Points to be noted:

 

·          Both only return enabled ShippingMethods in the system.

·          GetShippingMethods() returns ALL the enabled ShippingMethods in the system. Each languageId gets it’s own table.

·          GetShippingMethods(String languageId) returns the ShippingMethods for display for the languageId locale. The key point here is that it always returns all the ShippingMethods configured in the system, irrespective of whether they have a value defined for this languageId or not. If for a particular ShippingMethod the requested languageId is NOT found in the list of defined languages then the values for the DEFAULT languageId of the ShippingMethod is returned.

 

Nothing will probably make it clearer than an example. Imagine 2 ShippingMethods defined in the following languages:

 

 

LanguageId

Name

IsDefault

SM1

en-US

SM1_enUS

True

 

fr-FR

SM1_frFR

False

 

 

 

 

SM2

fr-FR

SM2_frFR

True

 

Now here is what happens when these APIs are called:

 

·          DataSet allSMs = OrderContext.Current.GetShippingMethods();

In the case of GetShippingMethods() 2 tables will be present in the dataset, one called “en-US” containing SM1_enUS and one table called “fr-FR” containing 2 methods SM1_frFR and SM2_frFR.

 

 

 

·          DataSet deSMs = OrderContext.Current.GetShippingMethods("de-DE");


In the case of  GetShippingMethods(String) only one table called “de-DE” will be returned but it shall contain 2 entries for each of the 2 enabled methods in the system as defined in their default languages, thus entries for SM1_enUS (default for SM1) and SM2_frFR (default for SM2) will be returned.

 

 

 

By the way, the same behavior applies to the OrderContext.GetPaymentMethods() and OrderContext.GetPaymentMethods(String) methods as well.

Published Monday, July 17, 2006 3:37 PM by nihitk

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Tuesday, July 18, 2006 8:53 AM

It´s interesting this behavior, and very good too. Thanks for this post!

André Nobre

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Wednesday, August 30, 2006 5:46 PM

I have a question regarding the shipping methods (and the payment methods too).  What exactly determines the order in which the methods come from the Get<type>Methods(string languageId)?  I currently have a helper method which receives the data table(s), and puts the rows into a type-safe collection.  The problem is knowing what methods will appear in what order.  So far I haven't found anything.  I have thought of performing a sort, but that doesn't really help me in this case.  I want to (if possible), set the order in which they would appear in, for example, a drop down, with my 'default' method being at the top of the list.  Or at least know consistently what the index of my 'default' value will be within this collection so I can set the drop down's selected index to it.

Thanks!

code_monkey

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Wednesday, August 30, 2006 8:03 PM

Hi,

There is no gauranteed order in which the methods are returned. The code is simply executing a select statement in SQL which doesn't sort by any explicit column.

You can take a look at the following stored procedures in the TransactionConfig database to see how the APIs return the data:
 GetShippingMethodsForAllLang
 GetShippingMethodsForLanguage
 GetPaymentMethodsForAllLang
 GetPaymentMethodsForLanguage

A sort on the PaymentMethodId should give you control over the order in which they appear in a dropdown list - I am not sure I understood that part of the question.

Thanks,
Nihit

nihitk

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Thursday, August 31, 2006 2:02 PM

Thanks for responding so quickly to my post.

What I meant with the drop down is that if I can somehow predicatably determine which method is going to appear first in the list, it would help me solve a UI requirement of having a default method always selected.

IE: if I have 5 shipping methods, and 'Ground' is the default, then it should always be either first in the list of choices, or always be the selected value.

code_monkey

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Thursday, August 31, 2006 3:42 PM

I would suggest taking a look at the StarterSite for the solution that has been implemented there. One way would be to put the ShippingGroupId in the web.config for the default ShippingMethod and then use this to populate the ListBox.

nihitk

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Tuesday, September 05, 2006 10:58 AM

I was thinking of using that method, however I don't want to have it dependant on the web.config file.  I figured the whole idea behind CS Customer and Orders manager is that a person could edit the values without the need for IT support.  The workaround I chose was to enter a numeric value for the method description, and sort my collection on it.

code_monkey

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Friday, January 19, 2007 3:05 PM

Hi, i want to retrieve the ShippingMethods as well as the corresponding shipping rates for each shipping method.  How do i do that? Please help.

Thanks,

;)Dinh

Dinh

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Friday, January 19, 2007 4:02 PM

Hi,

You cannot get the ShippingRates from the runtime side - this information is pulled 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

nihitk

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Friday, January 19, 2007 5:52 PM

Great, i am able to retrieves the shippingRates using the ShippingMethodManager.  Thanks!

dinhny

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Tuesday, July 03, 2007 5:08 PM

What happened to the overload with 3 arguments - OrderContext.GetShippingMethods (String, String, String[])?  The Migration documentation say's "Both the COM and the .NET Framework versions enable you to specify a filter criterion, a sort order, and the columns to return."  Nowhere have I seen any documentation to say that this was purposely removed.  We use this method all over in our current 2002 site.

Thanks,

- Scott

Scott Ewing

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Tuesday, July 03, 2007 7:31 PM

Hi Scott,

Thanks for the issue - it is an inaccuracy in the documentation - I have filed a bug to fix this issue in the next doc refresh.

The .Net API will always return the set of enabled ShippingMethods in the database. The only filter option is on the Language. This behavior is by design.

Thanks,

Nihit

nihitk

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Thursday, July 05, 2007 3:40 PM

Hi Nihit,

Thanks for getting back to me with the GetShippingMethods issue.  I also noticed that I can't find anything in the Migration documentation saying what happened to the OrderForm.DiscountsApplied property, as we used that as well.  Are you aware of any documentation available as to how to retrieve that same data.  The best I can tell is I have to retrieve it at the LineItem level using both the OrderLevelDiscountsApplied and the ItemLevelDiscountsApplied properties.

Thanks,

- Scott

Scott Ewing

# re: CS 2007: GetShippingMethods and GetShippingMethods(String) @ Monday, July 09, 2007 2:16 PM

Hi Scott,

No - I haven't been able to find anything around this as well. You are right in that this would need to be aggregated from the LineItem level (both the collections you mentioned) as well as the Shipments level (the ShippingDiscountAmount on each Shipment):

http://msdn2.microsoft.com/en-us/library/microsoft.commerceserver.runtime.orders.shipment.shippingdiscountamount.aspx

Thanks,

Nihit

nihitk

Leave a Comment

(required) 
required 
(required) 
Page view tracker