ShippingMethodManager.CreateMethodInstance

Ee785264.c++_on(en-US,CS.10).gifEe785264.vb_off(en-US,CS.10).gif

Use this method to create a new shipping method.

Definition

Function CreateMethodInstance(bOnDisk As Variant) As Variant

Parameters

bOnDisk

A Variant containing a Boolean indicating whether or not to create the shipping method on disk. This parameter is usually set to True.

Return Values

If this method completes successfully, it returns a Variant 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.

Error Values

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

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.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

Example

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

Call 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

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

' Set properties for the shipping method

Call oSMM.SetMethodConfig(Array("shipping_method_name", "My Shipping Method", "description", "Cheapest but slowest shipping method", "enabled", 1))

' Save the configured shipping method
oSMM.SaveMethodConfig

See Also

Splitter

Shipping Object

ShippingDiscountAdjust

ShippingManagerCache

ShippingMethodManager Object

ShippingMethodRouter

StepwiseShipping


All rights reserved.