This command prepares an order by determining prices, discounts, shipping charges, and taxes for an order. If an order reference number is not specified, all current pending orders will be prepared for the current customer at the given store.
Command structure
- http://host_name/path/
- The fully qualified name of your WebSphere Commerce Server and the configuration path.
Parameter values
- langId
- Sets or resets the preferred language for the duration of the session; the supported languages for a store are found in the STORELANG table
- forUser
- The logon ID of the user on whose behalf the command will be run; only a person with the authority to process orders can specify this parameter.
- forUserId
- Same as forUser, but identifying the user by the internal user ID, as found in the USERS table.
- URL
- (Required) The URL to be called when the command completes successfully.
- storeId
- The reference number of the store for which the order is to be prepared.
- orderId
- The reference number of the order to be prepared. If this parameter is omitted, this command defaults to the current pending orders. See Order abbreviations for a description. This parameter can be repeated.
- outOrderName
- Specifies the names of name-value pairs to be added to the redirection URL. The value of each added name-value pair is the reference number of the prepared order. If the name is not provided, the default name orderId will be used. This parameter can be repeated.
- commit
- Controls whether each order is processed in a separate database transaction. A value of 0 specifies that all orders be prepared in one transaction; a value of 1 specifies that a new transaction be started for each order to be prepared. The default value of this parameter is 0.
- remerge
- A list of the OrderItems that should be merged with other OrderItems in the same order and with the same correlationGroup attribute, if possible. OrderItems are not merged unless their InventoryStatus is "NALC", or they are specified by one or more of the allocate, backorder, and reverse parameters. This parameter can be repeated.
- merge
- A list of OrderItems that should be merged with other OrderItems in the same order if possible, regardless of their correlationGroup attributes. This parameter can be repeated.
- check
- A list of OrderItems that should be checked by the CheckInventory task command. This parameter can be repeated.
- allocate
- A list of OrderItems that should be allocated from existing inventory. This parameter can be repeated.
- backorder
- A list of OrderItems that should be allocated from expected inventory. This parameter can be repeated.
- reverse
- A list of OrderItems whose allocations should be released (that is, de-allocated from existing or expected inventory as appropriate). This parameter can be repeated.
Note: The remerge, merge, check, allocate, backorder and reverse parameters are applicable only if ATP inventory is enabled (see the ALLOCATIONGOODFOR column in the STORE table). They represent lists of OrderItems that will be passed to the AllocateInventory task command, which calls the CheckInventoryAvailability, AllocateExistingInventory, AllocateExpectedInventory , DeallocateExistingInventory, and DeallocateExpectedInventory task commands as specified below. Also, these parameters accept OrderItem abbreviations, which are detailed in the help for Order Management subsystem commands.
The default ATP parameter values are as follows:
- remerge=*
- merge=*n
- check=*n
- allocate=*
- backorder=*
- reverse=*
Example
The following example prepares the order with reference number 1 and redirects to the OrderDisplay command to view this order.
http://myhostname/webapp/wcs/stores/servlet/OrderPrepare?orderId=1 &URL=/webapp/commerce/OrderDisplay
Behavior
- Prepares the specified orders for display (by the OrderDisplay command) or processing (by the OrderProcess command). If no order numbers are specified, then the command will prepare all the current pending orders of the current customer, that belong to the specified store.
- If the value of the commit parameter is 1, a new database transaction is started for every order to be prepared. Otherwise, all orders are prepared in one transaction (the default behavior).
- The status of the specified orders must be one of 'P', 'I', 'E', 'W', or 'N'.
- The OrderPrepare command calls the
PrepareOrder task command to do the following for each of the specified
orders:
- Delete generated order items (refer to the PREPAREFLAGS column in the ORDERITEMS table.
- Check that all order items in the order are buyable (refer to the BUYABLE column in the CATENTRY table).
- If ATP inventory allocation is enabled (refer to the ALLOCATIONGOODFOR column in the STORE table), call the AllocateInventory task command to process the OrderItems identified by the ATP parameters (merge, remerge, check, allocate, backorder, and reverse), and obtain estimated availability times, shipping offsets, and fulfillment centers for allocated or backordered order items. Order items may be split or merged by this task command. The default implementation of this task command calls the GetEligibleFulfillmentCenters, CheckInventoryAvailability, AllocateExistingInventory, AllocateExpectedInventory, DeallocateExistingInventory, and DeallocateExpectedInventory task commands to perform the operations specified by the ATP parameters. These task commands the RECEIPT, RADETAIL, and their associated tables to determine existing and expected inventory availability.
- If ATP inventory is not enabled, call the ResolveFulfillmentCenter task command to assign a fulfillment center to each OrderItem, based on inventory availability. The default implementation of this task command calls the CheckInventory task command to determine inventory availability. The default implementation of the CheckInventory task command uses the INVENTORY table.
- Call the ValidateDynamicKitConfiguration task command.
- Obtain new unit prices for each order item, except those with manually overridden prices (refer to PREPAREFLAGS column of the ORDERITEMS table), by calling the GetContractSpecialPrice task command, or, if that is not defined, by calling the GetBaseSpecialPrice task command.
- Do not refresh prices for OrderItems whose prepareFlags attributes specify "quotation".
- Refresh prices and allocates inventory for OrderItems whose configurationId attribute is not null as if they were Dynamic Kits (that is, use the components in the OICOMPLIST table that reference the OrderItem) unless the prepareFlags attribute specifies "notConfigured".
- Multiply the quantity times the unit price for each order item, and store it in the TOTALPRODUCT column of the ORDERITEMS table.
- Re-calculate the amounts for calculation usages identified by the USAGEFLAGS column in the STENCALUSG table. First all the methods identified by CALMETHOD_ID_INI column of the STENCALUSG table are called. Then all the methods identified by CALMETHOD_ID_APP column are called. For backward compatibility, if the flag is set for usage -1, the ApplyOrderAdjustments task command is called, if it is defined in the CMDREG table, instead of the method identified by the CALMETHOD_ID_APP column in the STENCALUSG table. For backward compatibility, if this flag is set for usage -2, the ApplyOrderShippingCharges task command is called, if it is defined in the CMDREG table, instead of the method identified by the CALMETHOD_ID_APP column. For backward compatibility, if this flag is set for usage -3 and for -4, the ApplyOrderTaxes task command is called, if it is defined in the CMDREG table, instead of the methods identified by the CALMETHOD_ID_APP column in the STENCALUSG table.
- Re-create sub-orders (rows in the SUBORDERS table) for each distinct shipping address, and then summarize the re-calculated information for each of the sub-orders by calling the methods identified by CALMETHOD_ID_SUM column in the STENCALUSG table for each calculation usage identified by the CALUSGAEFLAGS column.
- Lock the order to indicate that it is ready for the OrderProcess command. The lock can be reset either by expiry, by changing the Order (for example by using the OrderItemUpdate command), or explicitly by using the OrderUnlock command. The expiry period for a lock is stored in the QUOTEGOODFOR column of the STORE table.
Exception conditions
- If no orders match the specified parameters, the command throws the ECApplicationException exception specifying the ErrorOrderNoneCmd error view command.
- If any of the products or items in the order are not buyable, the command
throws the ECApplicationException exception specifying the
BadOrderDataErrorView error view command.
For further information on exceptions conditions for order errors, refer to Error Codes for Order Error Views. - The command throws the ECApplicationException exception specifying the
RetrievePriceErrorView error view command if
any of the following conditions are true:
- Input trading agreements (contracts) are not valid or eligible for use.
- Trading agreements (contracts) being used in the order apply incompatible payment methods.
- Price Lists cannot be retrieved for any of the products or items.
- If any calculation indicated by the USAGEFLAGS column in the STENCALUSG table was unable to calculate a value for each order item in an order, and if the USAGEFLAGS column in the STENCALUSG table indicates that a value must be calculated, then an ECApplicationException exception is thrown.
- If an Order has no OrderItems, an ECApplicationException exception is thrown.