0% found this document useful (0 votes)
36 views2 pages

Interview Prep WCS 2023

In IBM WCS, when a guest user logs in after adding items to their cart, the system creates a new OrderId associated with the guest user. The MigrateUserEntriesCmd task command is responsible for migrating the guest's resources, including current orders, to the registered user, with the option to merge shopping carts if configured. The process involves setting the appropriate flags and using specific methods to handle the migration of order items and user resources.

Uploaded by

sunil.puppala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Interview Prep WCS 2023

In IBM WCS, when a guest user logs in after adding items to their cart, the system creates a new OrderId associated with the guest user. The MigrateUserEntriesCmd task command is responsible for migrating the guest's resources, including current orders, to the registered user, with the option to merge shopping carts if configured. The process involves setting the appropriate flags and using specific methods to handle the migration of order items and user resources.

Uploaded by

sunil.puppala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

In IBM WCS, what happens when a user logs in after adding an item to cart as a

guest. How is the orderId handled in this scenario?

But the Trick here is :-

public class MigrateUserEntriesCmdImpl


extends TaskCommandImpl
implements MigrateUserEntriesCmd
This task command is used to migrate resources owned by one user to another. The
mandatory resources that are migrated are Addresses, Current Orders, Interest
Items, Order Items, Orders, and Order templates.

By default, this command will not merge the shopping cart for the 2 users, but it
can be configured to do so by:

a) Setting the mergeCart flag in the request property in the command context to
true.

OR:

b) Setting MemberSubSystem/MergeCartsAtAuthentication/enabled in the wc-server.xml


to true. The mergeCart flag in the request property will take higher priority.

Before executing this task command the following sets should be performed:

setOldUser() -->getOldUser()

This method retrieves the old user whose resources are to be migrated to the new
user.

setNewUser() -->getNewUser()

This method retrieves the new user who is the recipient of migrated resources from
the old user.

These both OldUser and NewUser will be able to retrieve from UserAccessBean of
concern JSP.

migrateOrderItem(OrderItemAccessBean abOrderItem, UserAccessBean abNewUser,


CommandContext newUserCmdCtx)
This method migrates an order item to a new user.

=============================================================

First, some review about User lifecycle in WCS commerce : 1- user visited the site
as generic user with USER ID = -1002 2- when user add any item to his shopping cart
, WCS create an OrderId and assign it to new USER ID created and user called
"guest" in this case (both #1 and #2) have userType=G 3- when user log in using
login form it is by default attached to LogonCmd in struts configuration , and if
you decompile that controller command you will see that it is calling
MigrateUserEntriesCmd task command which responsible for migrating Addresses,
Current Orders, Interest Items, Order Items, Orders, and Order templates. the new
orderID that is used is the Registered OrderId .

I suggest you use decompiler installed to your RAD so you can decompile IBM classes
for better understanding of the logic and then customize your code as IBM best
practice (extending commands .. etc ) I use JAD eclipse plugin for decompilation .
you can further read (references):
http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/index.jsp?topic=
%2Fcom.ibm.commerce.admin.doc%2Fconcepts%2Fcmsmembers.htm&resultof%3D
%2522%2555%2553%2545%2552%2553%2522%2520%2522%2575%2573%2565%2572%2522%2520

http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/index.jsp?topic=
%2Fcom.ibm.commerce.api.doc%2Fcom%2Fibm%2Fcommerce%2Fsecurity%2Fcommands
%2FMigrateUserEntriesCmdImpl.html

============================================================

In login page add this code when user Guest and OrderItemMove is out of box command
used

<pre>
<c:if test="${userType == 'G'}">
<wcf:url var="orderMove" value="OrderItemMove" type="Ajax">
<wcf:param name="toOrderId" value="."/>
<wcf:param name="deleteIfEmpty" value="*"/>
<wcf:param name="fromOrderId" value="*"/>
<wcf:param name="continue" value="1"/>
<wcf:param name="createIfEmpty" value="1"/>
<wcf:param name="calculationUsageId" value="-1" />
<wcf:param name="calculationUsageId" value="-2" />
<wcf:param name="calculationUsageId" value="-7" />
<wcf:param name="updatePrices" value="0"/>
</wcf:url>
</c:if>
</pre>
Button javascript code User clicks on :

LogonSubmit(document.Logon,'<c:out value='${orderMove}'/>','<c:out value='$


{afterOrderCalculateURL}'/>');void(0);">
After validation and form the URL

function LogonSubmit{
var completeOrderMoveURL = orderMoveURL;
completeOrderMoveURL = completeOrderMoveURL + "&URL=OrderCalculate?URL=" +
afterOrderCalculateURL +"&calculationUsageId=-1&calculationUsageId=-
2&calculationUsageId=-7";
document.getElementById('URL').value = completeOrderMoveURL;
}
//Then submit the form
form.submit();
I hope this Help for merging the items after login

============================================================

You might also like