Friday, September 19, 2025

HCL Commerce Order Flow Explained: Controller & Task Commands in Detail

 

🛒 HCL Commerce Order Flow Explained: Controller & Task Commands in Detail

HCL Commerce (previously WebSphere Commerce) is one of the most powerful enterprise eCommerce platforms. At its core lies a command framework that orchestrates the entire order lifecycle — from adding an item to the cart, all the way to payment and fulfillment.

For developers, mastering the Order Subsystem is essential — whether you’re customizing checkout, debugging pricing issues, or extending payment flows. In this blog, we’ll take a deep dive into order flows, breaking down Controller Commands, their Task Commands, and even the nested Controller Commands invoked behind the scenes.


🔹 Understanding the Command Framework

  • Controller Commands → The main entry points invoked via REST APIs, JSPs, or schedulers. They orchestrate the higher-level business process.

  • Task Commands → Smaller, reusable commands called within controller commands. They perform specific business logic (pricing, tax, inventory checks, etc).

👉 One key detail: Controller Commands often trigger other Controller Commands, creating a layered flow.


🔹 Key Controller Commands in Order Lifecycle

Here’s the list of primary controller commands in the order subsystem:

  1. OrderCreateCmd – Creates a new order (cart).

  2. OrderItemAddCmd – Adds items to the cart.

  3. OrderItemUpdateCmd – Updates quantity/configuration.

  4. OrderItemDeleteCmd – Removes items.

  5. OrderCalculateCmd – Calculates prices, promotions, taxes, shipping.

  6. OrderPrepareCmd – Prepares order for checkout.

  7. OrderSubmitCmd – Submits order for payment & fulfillment.

  8. OrderCancelCmd – Cancels orders.


🔹 Detailed Command Flow (Controller + Task + Related Controllers)

1. OrderCreateCmd (Create Cart)

  • Task Commands: Initializes a new order object, default shipping mode, currency, and store settings.

  • Related Controllers: None at this stage.


2. OrderItemAddCmd (Add Items to Cart)

  • Task Commands:

    • CheckInventoryAvailabilityCmd

    • OrderCalculateDiscountCmd

    • OrderCalculateTaxCmd

  • Related Controllers:

    • OrderCalculateCmd (to update totals)

    • OrderUpdateCmd (to persist order updates)


3. OrderItemUpdateCmd (Update Cart Items)

  • Task Commands:

    • CheckInventoryAvailabilityCmd

    • OrderCalculateDiscountCmd

    • OrderCalculateTaxCmd

  • Related Controllers:

    • OrderCalculateCmd (to recalc totals)

    • OrderPrepareCmd (if checkout is in progress)


4. OrderItemDeleteCmd (Remove Item)

  • Task Commands:

    • OrderCalculateDiscountCmd

    • OrderCalculateTaxCmd

  • Related Controllers:

    • OrderCalculateCmd (refresh totals after removal)


5. OrderCalculateCmd (Recalculate Totals)

  • Task Commands:

    • OrderCalculateShippingCmd

    • OrderCalculateTaxCmd

    • OrderCalculateDiscountCmd

  • Related Controllers:

    • Called by OrderItemAddCmd, OrderItemUpdateCmd, OrderItemDeleteCmd, OrderPrepareCmd.


6. OrderPrepareCmd (Prepare for Checkout)

  • Task Commands:

    • PrepareOrderTaskCmd

    • CheckInventoryAvailabilityCmd

  • Related Controllers:

    • OrderCalculateCmd (final pricing)


7. OrderSubmitCmd (Submit Order)

  • Task Commands:

    • CheckPaymentAuthorizationCmd

    • ProcessOrderTaskCmd

  • Related Controllers:

    • OrderPrepareCmd (ensures readiness)

    • OrderCalculateCmd (final consistency check)


8. OrderCancelCmd (Cancel Order)

  • Task Commands:

    • ProcessOrderTaskCmd (to rollback state and reverse payments)

  • Related Controllers:

    • OrderUpdateCmd (persists cancellation info)


🔹 End-to-End Order Flow (Cart → Checkout → Submit → Cancel)

  1. Create Order: OrderCreateCmd

  2. Add Items: OrderItemAddCmd → triggers OrderCalculateCmd

  3. Update/Delete Items: OrderItemUpdateCmd / OrderItemDeleteCmd → triggers recalculation

  4. Prepare Checkout: OrderPrepareCmd → validates inventory & totals

  5. Payment: OrderChangePaymentCmd → updates & authorizes payments

  6. Submit: OrderSubmitCmd → finalizes order for fulfillment

  7. Cancel (if needed): OrderCancelCmd → reverses/rolls back order


🔹 Why Developers Should Know This

  • Customization → Override specific Task Commands instead of rewriting full flows.

  • Debugging → Knowing which commands fire in sequence helps pinpoint issues faster.

  • Performance → Identify heavy command chains & optimize them.

  • Interviews → Order flow is one of the most frequently asked topics for senior HCL Commerce developers.


🔹 Final Thoughts

HCL Commerce’s order subsystem may look complex, but once you understand the hierarchy of Controller Commands, their Task Commands, and nested Controller calls, the system becomes highly predictable. This knowledge is the key to effective customization, troubleshooting, and scaling your commerce solution.


🔹 Hashtags

#HCLCommerce #WebSphereCommerce #OrderFlow #EcommerceDevelopment #ControllerCommands #TaskCommands #JavaCommerce #HeadlessCommerce #OrderManagement #CommerceDeveloper  #IBMWebSphereCommerce

Thursday, September 18, 2025

Creating a new entity bean or EJB in IBM WCS

The best source for this task is the info center so refer below link:

https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.tutorial.doc/tutorial/ttd18.html

I will share some points on this for each step that will help in completing this task while referring to Infocenter.

Most Important: 

Before starting EJB Creation finalize the table structure and data model as some steps cannot be corrected rather have to restart the complete process of EJB Creation.

Note:  Every step below please save your changes without fail. 


Step-1: Start the server in normal mode or debug mode. 

Step-2: Creating Table structure 

  • Create a table as per your requirement, define the data model finalize the table structure.
  • Use SQL client or the db.jsp to run the new table creation Query        

Step-3, 4: Creating table in the Database

Enter and Execute/Run the query, commit the changes in SQL client or db.jsp

Step-5: Creating BEAN and its CMP fields 

In this follow info center till steps d.

- Create all the primary keys if your table has multiple primary keys and for all primary key cmp creation select Key Field checkbox, all other checkboxes by default will be disabled.

- Select corresponding datatypes accordingly.

-  For fields other than primary keys, select Access with getter and setter methods checkbox.

- Clear the Promote getter and setter methods to remote interface checkbox, select only if it's applicable only in your case. refer info center for an explanation.

- Create all the fields as per your table defined (refer screenshot).

- Creating optcounter field is optional but preferred.

- Follow this step 'E' as is.

- The four files must be created  as shown in the below screenshot, if not then something is messed while creating and saving. Restart the EJB creation process in the fresh workspace (else it may lead to conflicts).

Step-6, 7, 8, 9: Follow steps as mentioned in the info center, those are pretty straightforward.

Step-10: Creating/Generating the getters
-
In this step, we should create or add the getters for all the primary key fields

- Create getters to all the primary key fields, can create getters manually or by generating the code.

- To generate the code right-click in the bean class, and choose the option as shown below


- Select fields for which you need the getters and select only getter methods.

Step-11: Creating finders

- Follow all the steps until step 'F'.

- In step f, if the table would have multiple rows for the field whose finder is being created then should select the return type as "java.util.Enumeration".

Refer Detailed info center link on how to create finders:

https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.doc/tasks/tdecreateentitybean_6.html

- Follow other steps as is.

Step-12: Creating new ejbCreate and ejbPostCreate methods

- The initial ejbCreate() method that gets generated might not initialize all non-nullable fields so write a custom overridden method with all the non-nullable fields.

- ejbCreate() is for creating the row in DB with all necessary parameters/fields.

- If any modifications in ejbCreate() after promoting it to the home interface, then we should demote make changes and promote it again.

Detailed link on Creating ejbCreate method:

https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.doc/tasks/tdecreateentitybean_7.html

- All other steps should be followed as mentioned in the info center.

Step-13: Adding getOwner() and fulfills() methods

- Add these methods only if the table is independent and has no foreign key reference

- If the table has a foreign key reference then these two methods are not needed still they get autogenerated in the access bean after it is generated.

- If still need to add these methods then as in the shown example just create the methods following the info center steps.


Step-14: Creating a database and table definition

- In This, The info center steps 'A' till 'F' are not needed if the Schema was already created (follow info center steps to create the schema if not present).

- Follow the step 'G' to navigate to data models

- Don't have to follow step 'H' if the Schema was already created rather select the schema.

- Follow steps 'I' and 'J' as in from the info center.

- In Step 'J', The table fields/parameters while creating the table should match with the database table field names else it fails. 

Step-15: Mapping table fields and java fields

- This step is crucial to map the java fields and DB fields (Created in step 14) that were created above.

- Follow the steps as is, if the backend folder is already there then you just select it and proceed.

-Here while mapping can use any type of mapping such that match by type or match by name, preferable is match by type as this would map most of the fields.

- Once it has mapped cross-check if the mapping is right if not drag-drop and match the fields appropriately and save the file.

Step-16: Enabling Optimistic Locking

- Follow the steps as is in the info center

Step-17: Set the optimistic predicate value of the optcounter field

- Follow the steps as is in the info center

Step-18: Editing methods to call optimistic locking classes.

- Follow the steps as is in the info center.

- In Step C, for adding the below code
 BonusKey myNewKey = new BonusKey();
 this.initializeOptCounter(myNewKey);

- In the above reference instead of the memberId, pass all the primary keys.

- If you have one primary key pass that or if you have multiple then pass those all in the right order, for the order check the beanKey class.

Step-19: Creating an access bean

- Just follow the steps in the info center

Step-20: Generating the deploy code

- Just follow the steps in the info center

Step-21: Generating the Access Bean

- Just follow the steps in the info center

References:

Creating Entity Beans infocenter link:
https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.tutorial.doc/tutorial/ttd18.html

Details reference for creating finders:
https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.doc/tasks/tdecreateentitybean_6.html

Detailed link on Creating ejbCreate method:

https://help.hcltechsw.com/commerce/7.0.0/com.ibm.commerce.developer.doc/tasks/tdecreateentitybean_7.html 

Datatype mapping reference:

Which Files to commit after creating entity bean?



Thanks for reading my blog!!

Sharing Is Caring!!!!!!