Merging / Migrating / Combining User Session Data (Cart Merge while User Logon in Websphere Commerce)
Cart Merge while User Logon in Websphere Commerce
MigrateUserEntriesCmdImpl
MigrateUserEntriesCmd will not do merge. It just migrates guest user details to current logged in user. We will have to use OrderItemMoveCmd for merge. OrderitemMoveCmd can only merge different orders of same customer only. That’s the reason we call MigrateUserEntriesCmd from LogonCmd first, followed by OrderItemMoveCmd.
Consider the below order flow.
Register a new user "testuser" in the site and logout before adding any items to cart.Come back to the site as a guest user.Add an item to cart .During checkout try to login as "testuser" registered before.Order\OrderItems memberId will be changed from guest to that of registered user. There willn't be any order left for the Guest user.This can be achived with the help of MigrateUserEntriesCmdImpl.
This task command is used to migrate resources owned by one user to another. The mandatory resources that are migrated are Addresses.By default, this command will not merge the shopping cart for the 2 users.For e.g it does not do anything if the logged in user has a previous shopping cart. That scenario is handled with the help of OrderitemMoveCmd.
OrderItemMoveCmdImpl
Consider the below order flow.
Come to the site as a registerd user and add items to cart .Logout from the site.Now the registered user has a pending order.Again come to the site as as guest user and add an item to cart.During Check out login as registred user "testuser".The guest order will be removed and items will be copied to the registered user.For that reason we will call logonCmd which will call MigrateuserentriesCmd (Which copies items from guest to registered)followd by OrderItemMoveCmd.
Customize the
Stores\WebContent\StoreFronAssetStore\UserArea\AccountSection\LogonSubsectionUser\UserLogonForm.jsp file.
In the UserLogonForm.jsp file, replace
<input type="hidden" name="URL" value="<c:out value="${continueAfterLogonURL}"/>" id="WC_UserLogonForm_FormInput_URL_In_Logon_1"/>
With the following code snippet:
<c:url var="orderMove" value="OrderItemMove">
<c:param name="URL" value="OrderCalculate?URL=StoreCatalogDisplay"/>
<c:param name="page" value="account"/>
<c:param name="fromOrderId" value="*"/>
<c:param name="toOrderId" value="."/>
<c:param name="deleteIfEmpty" value="*"/>
<c:param name="continue" value="1"/>
<c:param name="createIfEmpty" value="1"/>
<c:param name="calculationUsageId" value="-1"/>
<c:param name="updatePrices" value="1"/>
<c:param name="storeId" value="${storeId}"/>
</c:url>
<input type="hidden" name="URL" value="<c:out value='${orderMove}' />" id="WC_RememberMeLogonForm_FormInput_URL_In_Logon_1" />
MigrateUserEntriesCmdImpl
MigrateUserEntriesCmd will not do merge. It just migrates guest user details to current logged in user. We will have to use OrderItemMoveCmd for merge. OrderitemMoveCmd can only merge different orders of same customer only. That’s the reason we call MigrateUserEntriesCmd from LogonCmd first, followed by OrderItemMoveCmd.
Consider the below order flow.
Register a new user "testuser" in the site and logout before adding any items to cart.Come back to the site as a guest user.Add an item to cart .During checkout try to login as "testuser" registered before.Order\OrderItems memberId will be changed from guest to that of registered user. There willn't be any order left for the Guest user.This can be achived with the help of MigrateUserEntriesCmdImpl.
This task command is used to migrate resources owned by one user to another. The mandatory resources that are migrated are Addresses.By default, this command will not merge the shopping cart for the 2 users.For e.g it does not do anything if the logged in user has a previous shopping cart. That scenario is handled with the help of OrderitemMoveCmd.
OrderItemMoveCmdImpl
Consider the below order flow.
Come to the site as a registerd user and add items to cart .Logout from the site.Now the registered user has a pending order.Again come to the site as as guest user and add an item to cart.During Check out login as registred user "testuser".The guest order will be removed and items will be copied to the registered user.For that reason we will call logonCmd which will call MigrateuserentriesCmd (Which copies items from guest to registered)followd by OrderItemMoveCmd.
Customize the
Stores\WebContent\StoreFronAssetStore\UserArea\AccountSection\LogonSubsectionUser\UserLogonForm.jsp file.
In the UserLogonForm.jsp file, replace
<input type="hidden" name="URL" value="<c:out value="${continueAfterLogonURL}"/>" id="WC_UserLogonForm_FormInput_URL_In_Logon_1"/>
With the following code snippet:
<c:url var="orderMove" value="OrderItemMove">
<c:param name="URL" value="OrderCalculate?URL=StoreCatalogDisplay"/>
<c:param name="page" value="account"/>
<c:param name="fromOrderId" value="*"/>
<c:param name="toOrderId" value="."/>
<c:param name="deleteIfEmpty" value="*"/>
<c:param name="continue" value="1"/>
<c:param name="createIfEmpty" value="1"/>
<c:param name="calculationUsageId" value="-1"/>
<c:param name="updatePrices" value="1"/>
<c:param name="storeId" value="${storeId}"/>
</c:url>
<input type="hidden" name="URL" value="<c:out value='${orderMove}' />" id="WC_RememberMeLogonForm_FormInput_URL_In_Logon_1" />
Comments
Post a Comment