The first step in working with Commerce objects is to create an Order. A shopping cart is an implementation of the Order interface. To create an Order, you must have a reference to an OrderManager or SimpleOrderManager. Once you have the reference, use createOrder() to create the new Order.

There are many versions of the createOrder method, each of which takes a different set of parameters:

All methods create an Order object and assign it a unique ID. The type of Order created depends on the method used. If the method takes an orderType parameter, that parameter determines the type of object that is constructed. Otherwise, the defaultOrderType property of the OrderTools component (see OrderTools in this chapter) defines the Order type.

By default, an Order contains one empty ShippingGroup and one empty PaymentGroup when it is created, and their types are determined by the defaultShippingGroupType and defaultPaymentGroupType properties of the OrderTools component.

Note: If you do not want to create an empty ShippingGroup and an empty PaymentGroup for every new Order, set the createDefaultShippingGroup and createDefaultPaymentGroup properties in the OrderTools component to false.

The following example demonstrates how to create an Order:

// Get a reference to the OrderManager
OrderManager orderManager = (OrderManager)

// Create the Order
Order order = orderManager.createOrder(profileId);

By default, orders are persistent. To disable persistence, set the persistOrders property in the ShoppingCart component to false. The ShoppingCart component is located in Nucleus at /atg/commerce/.