Share via


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.

Comments

  • Anonymous
    July 18, 2006
    It´s interesting this behavior, and very good too. Thanks for this post!

  • Anonymous
    August 30, 2006
    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!

  • Anonymous
    August 30, 2006
    The comment has been removed

  • Anonymous
    August 31, 2006
    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.

  • Anonymous
    August 31, 2006
    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.

  • Anonymous
    September 05, 2006
    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.

  • Anonymous
    January 19, 2007
    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

  • Anonymous
    January 19, 2007
    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

  • Anonymous
    January 19, 2007
    Great, i am able to retrieves the shippingRates using the ShippingMethodManager.  Thanks!

  • Anonymous
    July 03, 2007
    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
  • Anonymous
    July 03, 2007
    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

  • Anonymous
    July 05, 2007
    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