OrderGroup.SaveAsOrder

Ee798683.c++_on(en-US,CS.10).gifEe798683.vb_off(en-US,CS.10).gif

Use this method to save the OrderGroup to the database with an order status.

Definition

Function SaveAsOrder(Optional vtOutTrackingNumber As Variant) As Variant

Parameters

vtOutTrackingNumber

A Variant that specifies the tracking number. If specified, this Variant must be a non-literal value; when the method returns, it will contain the tracking number.

Return Values

If this method completes successfully, it returns a Variant that specifies the OrderGroupID.

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

This method sets the OrderGroup status to "order" if the current status is Template, Basket, or undefined. (All other states are left alone; this allows orders to be in many states, such as pending approval, rejected, and so on.) You can set the state to any value except basket or template before calling the SaveAsOrder method; this method will not overwrite the state.

If this is the first time the order is saved, a special field will be written that records the order creation date. If an OrderTrackingNumber already exists on the OrderForm (under the key order_number) before the save, a new one will not be generated. This feature allows for ERP-based tracking numbers.

If the OrderGroup was loaded from a template, or from a basket, this method will generate a new OrderGroupID and tracking number, and perform a database insert. If the OrderGroup does not yet exist on disk, this method will generate an OrderGroupID and tracking number and perform a database insert. If the OrderGroup was loaded from any other state, this method will perform a database update.

If you load a basket or template and call the SaveAsOrder method, the basket or template remains unchanged on disk. For this reason,a call to the SaveAsOrder method is typically followed by a call to OrderGroupManager.DeleteOrderGroupFromDisk.

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

Example

' oOrderGroup is a Commerce.OrderGroup object
' vResult is a Variant
' vTrackingNumber is a Variant
vResult = oOrderGroup.SaveAsOrder(vTrackingNumber)

See Also

OrderGroup Object

OrderGroup.SaveAsBasket

OrderGroup.SaveAsTemplate


All rights reserved.