ShippingMethodManager.CreateMethodInstance Method (PIA)

Use this method to create a new shipping method.

Definition

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Orders
…
Public Function CreateMethodInstance(ByRefbOnDisk As Object) As Object

[C#]

using Microsoft.CommerceServer.Interop.Orders;
…
public object CreateMethodInstance(
  ref object bOnDisk);

Parameters

[Visual Basic .NET]

  • bOnDisk
    An Object containing a Boolean indicating whether or not to create the shipping method on disk. This parameter is usually set to True.

[C#]

  • bOnDisk
    An object containing a bool value indicating whether or not to create the shipping method on disk. This parameter is usually set to True.

Return Values

[Visual Basic .NET] If this method completes successfully, it returns an Object containing a string that is the method ID of the new shipping method. The method returns an empty string when the bOnDisk parameter is False.

[C#] This method returns an object containing a string that is the method ID of the new method. It is set to an empty string value if the bOnDisk parameter is False.

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

Remarks

If the shipping method is created to be saved on disk (the bOnSaved parameter is True), the function adds a new record to the current recordset with the enabled column value set to zero (0) and the shipping_method_id column set to the new shipping method ID.

[Visual Basic .NET]

Example

' Initialize the ShippingMethodManager object
' oSMM is a Commerce.ShippingMethodManager object
' MSCSTransactionConfigConnStr is sConnectionString, a string containing
' the connection string 

oSMM.Initialize(MSCSTransactionConfigConnStr)

' Create a new shipping method
' bOnDisk is set to True
' sShippingMethodID is sMethodID
sShippingMethodID = oSMM.CreateMethodInstance(True)

' Set the configuration data for the pipeline component
' sProgID, sAction, and sActionFrientlyName are strings
' dConfigDict is a Commerce.Dictionary object

oSMM.SetCachableComponentConfig(sProgID, dConfigDict, _
                 sAction, sActionFriendlyName)

' Set properties for the shipping method
Dim aParamsAndValues as System.Array
aParamsAndValues(0) = "shipping_method_name"
aParamsAndValues(1) = "My Shipping Method"
aParamsAndValues(2) = "description"
aParamsAndValues(3) = "Cheapest but slowest shipping method"
aParamsAndValues(4) = "enabled"
aParamsAndValues(5) = 1

oSMM.SetMethodConfig(aParamsAndValues)

' Save the configured shipping method
oSMM.SaveMethodConfig()

Requirements

Namespace: Microsoft.CommerceServer.Interop.Orders

Platforms: Windows 2000, Windows Server 2003

Assembly: cs_shipmgr (in cs_shipmgr.dll)

See Also

Splitter

Shipping Class

ShippingDiscountAdjust

ShippingManagerCache

ShippingMethodManager Object

ShippingMethodRouter

StepwiseShipping

Copyright © 2005 Microsoft Corporation.
All rights reserved.