Websphere Commerce Order Subsystem


Order Management subsystem is a component of the WebSphere Commerce Server that provides shopping carts, order capture, order fulfillment, inventory, and payment function support.

First let us go through concept of Requisition Lists in Websphere Commerce.


Requisition Lists

Requisition list is created for ordering items frequently .There can be two types of Requisition lists.

1. Private Requisition List –This can be viewed and modified by the user who creates it.
2. Shared Requisition List-This can be viewed and used by users in the same organization.

Requisition lists are stored in ORDERS table. In ORDERS table STATUS column is used to identify the requisition lists. A value of Y indicates that it is a private requisition list. A value of Z indicates that it is a sharable requisition list. If you need to change the type of requisition list you must call the RequisitionListUpdateCmd.

Users can add items from requisition list to order and requisition list remain unaltered.

Commands Used for managing Requisition List are as follows

RequisitionListCreateCmd
This  controller command is used for  creating an empty requisition list.

RequisitionListUpdateCmd
This command changes a requisition list type from private to shared, or from shared to private. It also updates the billing and payment information.

RequisitionListItemUpdateCmd
This command  adds, updates, and deletes items in a requisition list.

RequisitionListDisplayCmd
This command  displays one or more requisition lists.

RequisitionListDeleteCmd
This command  deletes one or more requisition lists.

RequisitionListCopyCmd
This command  copies an existing order or requisition list to a new requisition list.

RequisitionListSubmitCmd
This command submits a requisition list for order processing. This command first copies the requisition list and creates a new pending order by calling the OrderItemUpdate command. Then it calls the OrderPrepare command to prepare the order and redirect to the respective URL.

Now Let us go through the concept of wish list / InterestItemList in WCS


Wish list / InterestItemList 

Wish List or interest item list is used for keeping the items which can be added to shopping cart at a later point of time.IN WCS 7 Feature pack 1 Gift List SOA service has been added to support both multiple wish list and gift center function. For gift registries, there is no change to the underlying database schema. .
  
Add to wish list Functionality 

In the case of single  wish list  it calls the   InterestItemAdd  and it populates the  IITEMLIST, IITEM tables.
In the case of multiple wish list it calls the   GiftCenterFacadeClient.createGiftList() followed by calling  GiftCenterFacadeClient.addItem() .It populates the GRGFTREG, GRGFTITM tables.
  
Remove from wish list Functionality

In the case of single wish list it calls the   InterestItemDelete and it updates the  IITEM  Table to remove the item. In the case of multiple wish lists it calls the   GiftCenterFacadeClient. updateItem () to remove item from GRGFTITM table.

Commands Used for managing wish List are as follows

InterestItemAddCmd
This command adds one or more products, or items, or both, to one or more interest item lists.

InterestItemDeleteCmd
This command deletes catalog entries from one or more interest item lists.

InterestItemListDeleteCmd
This command deletes the specified interest item lists and all items in them.

InterestItemDisplayCmd
This command displays all the catalog entries and items in the specified interest item list or lists.

SetInterestItemListCmd
This command sets or resets interest item lists as current. Invoking this command is the only way to set or reset an interest item list as "current". Only registered users can execute this command.

InterestItemListCopyCmd
This command creates or updates an interest item list by copying interest items from one interest item list to another.

Wish List / InterestItemList Tables

Single Wish List Feature tables

IITEMLIST
Each row in this table represents an InterestItemList.
IITEM
Each row of this table represents an IItem in an IItemList.
CIITEMLIST
Each row in this table represents the relationship between an IItemlist and a member to which it is the current list.

Multiple Wish List Feature tables


GRGFTREG
This table stores gift registry and wish list profile information.
GRGFTITM
This tables stores information about a gift registry and wish list item.
GRPERATTR
This table stores personalization attributes for gift registry and wish list items.

Follow below steps to Debug wish list features by enabling Trace

Enable below trace strings for existing single wish list feature
com.ibm.websphere.commerce.WC_CATALOG

Enable below Trace strings for multiple wish list feature
com.ibm.commerce.giftcenter.*

Order Subsystem Flow explained using Service Oriented Integration (SOI) Framework

Add To Cart
User clicks on add to cart it calls the OrderFacadeClient addOrderItem() method From there OrderItemAddCmd will be invoked. OrderItemAddCmd will in turn call the OrderCalculate and from there OrderItemDisplayCmd is invoked. OrderItemDisplayCmd will call the OrderItemDisplayView which will display the shopping cart with the newly added item.

Update Cart Item
User changes quantity and  clicks on update button it will call the  OrderFacadeClient updateOrderItem() method.From there OrderItemUpdateCmd will be invoked. OrderItemUpdateCmd will in turn call the OrderCalculate and then OrderItemDisplayCmd is invoked. OrderItemDisplayCmd will call the OrderItemDisplayView which will display the modified shopping cart.

Delete Cart Item
User clicks on delete control will go to OrderFacadeClient updateOrderItem() method .From there OrderItemUpdateCmd will be invoked. OrderItemUpdateCmd will inturn call the OrderCalculate and from there OrderItemDisplayCmd is invoked. The OrderItemDisplayCmd will call the OrderItemDisplayView which will display the modified shopping cart.

Checkout
User clicks on checkout it will call OrderFacadeClient updateOrderItem() method.From there  OrderItemUpdateCmd will be invoked. OrderItemUpdateCmd will in turn call the OrderCalculate and then forward to  the OrderShippingBillingView.

Enter Shipping\Billing Address
User enters shipping address and submit then control will go to OrderFacadeClient updateOrderShippingInfo() method. From there OrderItemUpdate command is called.OrderItemUpdate will call the OrderCalculate and will forward to OrderShippingBillingView.

Enter Payment Information
User Enters Payment information and press confirm order ,the client calls the order facade client method prepareOrder().This is followed by OrderFacdeClient addPaymentInstruction() method that invokes PIAddCmd and then forward to OrderSummaryView.If user updates the payment information OrderFacdeClient updatePaymentInstruction() method is called which inturn will call the PIEditCmd and will forward to OrderSummaryView. If user remove the payment information orderFacdeClient removePaymentInstruction() method is called which in turn will call the PIRemoveCmd and will forward to OrderSummaryView.

Place\Submit Order
User clicks on place or submit order OrderFacadeClient processOrder() method will be called. This in turn will call the Order Process command and will forward to the OrderShippingBillingConfirmationView.


Read the post on  Cart Merge While Login  to see more details




 Multiple Pending Orders

Multiple pending orders are usualy supported in a b2b stores for eg: Elite Store (Saved Order List) but we can use it in b2c as well with some customizations.

Saved Order List
Customers can use the Saved Orders list to view their current order, or to view a list of their saved orders and perform actions on those orders.

Custmizations to make sure that there are multiple pending orders for a single customer
Usually OrderItemAdd by default takes orderId=. as input, which means add current item to existing pending cart, instead if  we  change it to orderId=* while invoking addtocart, any guest or registered user will have multiple pending carts each time they do an addtocart.

CPENDORDER table row indicates that an order is marked as current for a customer in a store, if its status is "P" (Pending).

SetPendingOrderCmdImpl Set a pending order as the current pending order.


Complete Order Flow commands are listed below

OrderItemAddCmdImpl
This command adds items or products to the shopping cart. OrderItemAddCmdImpl calls the below commands in this sequence.
1)ResolveSkuCmdImpl
2)OrderCreateCmd
3)ResolveOrderItemPriceCmd
4)UpdateShippingAddressCmd
5)ValidateTradingPaymentCmd
6)DoInventoryActionCmd(CheckInventory)
7)UpdateShipInfoCmdImpl
8)RaiseOrderEventCmdImpl
9)OrderCalculateCmd
10)ExtendedOrderItemProcessCmd

1)ResolveSkuCmdImpl
This command finds the type of catalog entry. If it is a package then PackageResolveSkuCmd is called. If it is a product then this command determines the attributes required to resolve the product to an orderable item. If attributes are missing then ErrorMissingAttributeErrorCmd or ErrorProductAttributeErrorCmd is called.

2)OrderCreateCmd
This order command is used to create an order container with no line items.

3)ResolveOrderItemPriceCmd
This command is used to resolve price for a group of order items from one order.This command calculates the best price for the input OrderItems. It calls GetContractUnitPriceCmd or GetContractSpecialPriceCmd task command to calculate the price. If GetContractUnitPriceCmd/GetContractSpecialPriceCmd is not available, it calls GetBaseUnitPriceCmd/GetBaseSpecialPriceCmd. If input trading agreements and/or offers are specified, they will be used providing they are valid. Otherwise, eligible trading agreements will be obtained.

4)UpdateShippingAddressCmd
This Order task command is used to update the shipping address for the passed order items

5)ValidateTradingPaymentCmd
ValidateTradingPaymentCmd is called  to validate that the payment method is compatible with the trading agreement

6)DoInventoryActionCmd(CheckInventory)
If doInventory = Y, call DoInventoryActionCmd to update the fulfillment centers and check for available inventory

7)UpdateShipInfoCmdImpl
Call UpdateShipInfoCmd to update the shipping instructions, shipping account number and shipping charge type

8)RaiseOrderEventCmdImpl
Call RaiseOrderEventCmd to raise ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT

9)OrderCalculateCmd
If the flag calculateOrder is set then Call OrderCalculateCmd to do calculations that are based on the calUsageIds passed in

10)ExtendedOrderItemProcessCmd
Call ExtendOrderItemProcessCmd to execute any customization logic


OrderItemUpdateCmdImpl
OrderItemUpdateCmdImpl command updates order items in an existing Order.OrderItemUpdateCmdImpl   calls the following commands in sequence

1)DoInventoryActionCmd(Reserve Inventory)
2)AddOrderItemComponentsCmd
3)ResolveOrderItemPriceCmd
4)UpdateShippingAddressCmd
5)ValidateTradingPaymentCmd
6)DoInventoryActionCmd(Check Inventory)
7)updateShipInfoCmdImpl
8)RaiseOrderEventCmdImpl
9)OrderCalculateCmd
10)ExtendedOrderItemProcessCmd

1)DoInventoryActionCmd(Action : Reserve Inventory)
In ATP inventory systems it calls the command ReserveInventoryCmd. In Non-ATP inventory systems calls the UpdateInventoryCmd.

ReserveInventoryCmd
This command get the quantity available for the requested item, store, and fulfillment center.This command check to make sure that the quantity available is greater or equal to the quantity requested.If it is successful,obtain the ITEMFFMCTR row and increment the itemffmctr.qtyreserved by the requested quantity,then insert a new row into the INVRESERVE table.

UpdateInventoryCmd
UpdateInventory let you update inventory for items. There are two ways to update inventory.Set one or list of order items by calling setOrderItem method.Set one catalog entry by calling setCatEntryId, setQuantity and setStoreId methods. Method setQuantityMeasure is optional.

2)AddOrderItemComponentsCmd
This command creates the components that are associated with a composite order item. It derives the component list in one of two ways
1.    By making use of a  list of CatalogEntries that are passed in
2.    Get the list of components by finding all of the unassigned components through the given configuration id.

3)ResolveOrderItemPriceCmd
This command is called to calculate the best price and update order total.

4)UpdateShippingAddressCmd
This Order task command is used to update the shipping address for the order items passed in the request.

5)ValidateTradingPaymentCmd
ValidateTradingPaymentCmd is called to validate that the payment method is compatible with the trading agreement.
6)DoInventoryActionCmd(Check Inventory)

Check Inventory allows us to check inventory for items. There are two ways to check inventory.
1)      Set one or list of order items by calling setOrderItem method.
2)      Set one catalog entry by calling setCatEntryId, setQuantity and setStoreId methods. Method setQuantityMeasure is optional.

7)updateShipInfoCmdImpl
Call UpdateShipInfoCmd to update the shipping instructions, shipping account number and shipping charge type.

8)RaiseOrderEventCmdImpl
Call RaiseOrderEventCmd to raise ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT.

9)OrderCalculateCmd
If the flag calculateOrder is set Call OrderCalculateCmd to do calculations that are based on the calUsageIds passed in.

10)ExtendedOrderItemProcessCmd
Call ExtendOrderItemProcessCmd to execute any customization logic.

OrderItemDeleteCmdImpl
This command delete order items based on orderItemId or catEntryId specified.OrderItemDeleteCmdImpl calls below commands in sequence. 
1)DoInventoryActionCmd(ReserveInventory)
2)PrepareShipInfoCmd
3)ReolveOrderItemPriceCmd
4)OrderCalculateCmd

1)DoInventoryActionCmd(Action : Reserve Inventory)
In ATP inventory systems it calls the command reserveInventoryCmd. In Non-ATP inventory systems calls the updateInventoryCmd.
ReserveInventoryCmd
Get the quantity available for the requested item, store, and fulfillment center.Check to make sure that the quantity available is greater or equal to the quantity requested.If the above edit is successful,obtain the ITEMFFMCTR row and increment the itemffmctr.qtyreserved by the requested quantity,then insert a new row into the INVRESERVE table.
updateInventoryCmd
UpdateInventory let you update inventory for items. There are two ways to update inventory.Set one or list of order items by calling setOrderItem method.Set one catalog entry by calling setCatEntryId, setQuantity and setStoreId methods. Method setQuantityMeasure is optional.

2)PrepareShipInfoCmd
Perform a verification between the SHIPINFO table and the ORDERITEMS table and check for orphaned SHIPINFO records. Any orphaned records will be removed.

3)ReolveOrderItemPriceCmd
This command is used to resolve price for a group of order items from one order.This command calculates the best price for the input OrderItems.This command calls the GetContractUnitPriceCmd/GetContractSpecialPriceCmd task command to calculate the price.
If GetContractUnitPriceCmd/GetContractSpecialPriceCmd is not available, it calls the GetBaseUnitPriceCmd/GetBaseSpecialPriceCmd. If input trading agreements and/or offers are specified, they will be used providing they are valid. Otherwise, eligible trading agreements will be obtained.

4)OrderCalculateCmd
If the flag calculateOrder is set Call OrderCalculateCmd to do calculations that are based on the calUsageIds passed in.
  
OrderPrepareCmd (Controller Command)
Prepares an order by determining its prices, discounts, shipping charges, and taxes. If an order reference number is not specified, all current pending orders will be prepared for the current customer at the given store. The remerge, merge, check, allocate, backorder and reverse parameters are applicable only if ATP inventory is enabled (STORE Table INVENTORYSYSTEM column value -1).

OrderPrepareCmd  calls the following commands in sequence

1.PrepareOrderCmd(Task Command)
2.ValidateShippingAdjustmentCmd

PrepareOrderCmd(Task Command)
PrepareOrderCmd task command prepares an order by determine its prices, discounts, shipping charges, and taxes for an order. This command will also lock the order to indicate that it is ready for submission for the Order Process command. The lock can be reset either by expiry, by changing the Order during update or delete operations or by calling OrderUnlockCmd.The expiry period for a lock is stored in STORE table column QUOTEGOODFOR.
This command removes generated order item based on the prepare flags setting (PREPARE FLAG = 1 which means generated) in ORDERITEMS table. This command will also check if all order items are buyable and throw exceptions if they are not buyable. UpdateShippingAddressCmd is called to find the appropriate shipping address for all the order items and update them for each order item. For a dynamic kit ValidateDynamicKitConfigurationCmd is called to do validation. ResolveOrderItemPriceCmd is called to calculate the best price and update order total. DoInventoryActionCmd is called for inevntoy check and allocation .CalculateOrderCmd is called for calculation of charges.

ValidateShippingAdjustmentCmd
This Order task command is used to find any inconsistencies in the order's shipping adjustments. If new items have been added then the value returned from hasShoppingCartChanged() will be true else it will be false.

OrderProcessCmd (Controller Command)

This command submits an order for processing. The order must be locked by the Order Prepare command before calling this command.
 
OrderProcessCmd calls the following commands in the below sequence

1)PIAddCmd
This controller command is used to create a new payment method to an order.
2)ValidatePaymentMethodCmd
This command checks whether the payment method to be added comply with the Buy Online Pick In Store (BOPIS) rules.
3)ProcessOrderCmd
The ProcessOrderCmd task command makes the ProcessOrder server request.
4)RaiseOrdereventCmd
The RaiseOrderEventCmd task command is used to raise an order related event

ProcessOrderCmd (Task Command)

ProcessOrderCmd makes the ProcessOrder server request.ProcessOrderTaskCmd calls commands in sequence as shown below.

1)PreProcessOrderCmd
If Unified Business Flow is not enabled or is enabled and approval is needed then this command is called.
2)DoInventoryActionCmd(getATPParameter)
Call DoInventoryActionCmd to update inventory.
3)UpdateSependingLimitCmd
Call UpdateSpendingLimitCmd to check the trading agreement spending limit and validate the PO number.
4)PrimePaymentCmd
Call PrimePaymentCmd (EDP command) to guarantee that the customer has funds to pay for the order.
5)RaiseOrderSubmitEventCmd
Call RaiseOrderSubmitEventCmd to raise the order submit event.
6)PersisitOrdersWithMemberGroupIdsForCurrentUserCmd
PersistOrdersWithMemberGroupIdsForCurrentUserCmd (Marketing command) is called If OrdersMgpPersistListener is enabled in order to persist the orders_id with the member group id.
7)ExtOrderProcesCmd
ExtOrderProcessCmd command is called  to execute  any customization logic during order process flow.
8)TransferOrderCmd
This command confirms successful transfer of an order to an external system. This command is called to generate the outbound Order Create Message.
9)OrderMessagingCmd
This command generates the outbound Order Create Message "Report_NC_PurchaseOrder".

Tables Involved with Order Subsystem

ORDERS
Each row in this table represents an order in a store.

SUBORDERS
Each row of this table contains subtotals of amounts for all the OrderItems of an Order with the same shipping address.

ORDERITEMS
Each row of this table represents an order item in an order.

ORDPROMOCD
This table contains promotion codes captured for an order.
              
CPENDORDER
Each row of this table indicates that an order is marked as current for a customer in a store, if its status is "P" (Pending).

ORDPAYINFO
Each row in this table holds a name-value pair representing payment information for a particular Order. Values added to this table are encrypted when the "Instance/PDIEncrypt" configuration flag is "on".

ORDADJUST
Each row of this table represents an OrderAdjustment.

ORDIADJUST
Each row in this table represents an OrderItemAdjustment.

ORDADJTXEX
Each row of this table indicates that an OrderAdjustment is exempt from taxation of a particular TaxCategory. For example, an "after tax rebate" can be represented as a negative OrderAdjustment that is exempt from taxation of all TaxCategories.

ORDCALCD
Each row of this table indicates to the CalculationCodeCombineMethod that a CalculationCode is directly attached to all OrderItems in an Order. The order directCalculationCodeAttachment flag in ORDERITEMS.PREPAREFLAGS is 1.

ORDICALCD
Each row of this table indicates to the CalculationCodeCombineMethod that a CalculationCode is directly attached to an OrderItem. The attachment is not effective unless the directCalculationCodeAttachment flag in ORDERITEMS.PREPAREFLAGS is 1.

ORDTAX
Each row of this table represents the total of the tax amounts of a particular TaxCategory for all the OrderItems in an Order.

SUBORDTAX
Each row of this table specifies the tax amount of a particular TaxCategory for all the OrderItems with the same shipping address as the SubOrder.

ORDITAX
Each row of this table contains a tax amount of a particular TaxCategory, for an OrderItem. By default, WebSphere Commerce does not save any data in this table. However tax amounts are aggregated by TaxCategory in the SUBORDTAX and ORDTAX tables.

ORCOMMENT
The table stores the comments for an order entered by a customer service representative.

ORDERHIST
This table is used to save order snapshots in XML format.

ORDSTAT
This table contains information about the status of an order for an Order Status Update inbound message. Each row in the table contains information about a single order.

ORDUSERS
Contains information about users that worked with an order.





8 comments:

  1. Websphere commerce server --- "Websphere commerce server Online Training

    Send ur Enquiry to contact@21cssindia.com
    Product Overview
    Summary
    What is New
    Navigation,Search,Filter
    Accessibility
    System Architecture" more… Online Training- Corporate Training- IT Support U Can Reach Us On +917386622889 - +919000444287 http://www.21cssindia.com/courses/webspere-commerce-server-online-training-200.html

    ReplyDelete

  2. That's interesting! Can you please share more about it? Thank you.

    Order Management System

    ReplyDelete
  3. Hi Deepak,

    Can you give a blog regarding splitting of orders?
    I want to split my orders let's say based on fulfillment centers how would I do?

    ReplyDelete
  4. Delete Cart Item
    User clicks on delete control will go to OrderFacadeClient updateOrderItem() method .From there OrderItemUpdateCmd will be invoked. OrderItemUpdateCmd will inturn call the OrderCalculate and from there OrderItemDisplayCmd is invoked. The OrderItemDisplayCmd will call the OrderItemDisplayView which will display the modified shopping cart

    For Deleting Cart Item is it called deleteOrderItem() method and OrderItemDeleteCmd or updateOrderItem() method and OrderItemUpdateCmd

    ReplyDelete
  5. Selery Fulfillment is a 3PL company that helps eCommerce businesses through warehousing and personalized order fulfillment.

    ReplyDelete
  6. Small correction on Requisition List.

    Requisition lists are stored in ORDERS table. In ORDERS table TYPE column is used to identify the requisition lists. A value of 'PRL' indicates that it is a private requisition list. A value of 'SRL' .

    ReplyDelete
  7. Hi Deepak,

    Yours blog are so knowledgeable , I am so much impressed with the content.
    I just have one question how we are setting up prepare flags in orderitems table during order prepare journey.
    I know it is being set up by OOB code .But jsut need to know how it is setting up(command and criteria) what decides if the item will a gift or a normal item.It is based on promotion or any flags being set up in DB table ?

    ReplyDelete
  8. After research of fulfilment centres, we decided to go for Velocityship because of it’s great reputation. This is hands down the best fulfilment centre I have had the pleasure of using and the service we get on the account is over and above anything one would expect from a shipping company. Special thanks to team of velocityship for the most incredible service and for always going above and beyond to help whenever we have any questions.

    ReplyDelete