Persist Shopping cart after logout

1,185 views
Skip to first unread message

Avinash

unread,
May 22, 2012, 7:45:03 AM5/22/12
to ATG_Tech
Hi,
Please let me know how to persist the shopping cart after the user
logs out. Currently when the user logs out a new order object will be
created with no items in the cart. our requirement is such like when
the user logs out, his cart should be persisted

Naga

unread,
May 22, 2012, 8:15:10 AM5/22/12
to atg_...@googlegroups.com
ATG by default (OOTB) persists all items added to cart for a logged in
user, so you don't have to do anything unless you have changed some
configs or overridden some OOTB behavior, in which case please do
provide additional info as to what the overrides were for

-Naga
> --
> You received this message because you are subscribed to the Google Groups "ATG_Tech" group.
> To post to this group, send email to atg_...@googlegroups.com
> To unsubscribe from this group, send email to atg_tech-u...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/atg_tech?hl=en

Avinash

unread,
May 22, 2012, 8:28:57 AM5/22/12
to ATG_Tech
we have made the below changes.
in shoppingcart.properties
persistOrdersForAnonymousUsers=true
persistOrders=true
in cookieManager.properties
sendProfileCookies=true
in /atg/userprofiling/ProfileRequestServlet.properties
verifyBasicAuthentication=true
in /atg/dynamo/servlet/dafpipeline/profileRequestServlet.properties
persistAfterLogout=true
persistentAnonymousProfiles=true


These are the changes which we have done. the requirement is to
persist the shopping cart of a user when he logs out

Naga

unread,
May 22, 2012, 8:39:04 AM5/22/12
to atg_...@googlegroups.com
With these changes that you have done, have you verified that the
changes to the shopping cart is not being persisted to the database?
Can you please provide the steps that you used to verify the same?


As i mentioned earlier ATG OOTB by default would have persisted the
orders of logged in users (persistOrder=true in
/atg/commerce/ShoppingCart) is default true.

-Naga

Avinash

unread,
May 22, 2012, 9:27:30 AM5/22/12
to ATG_Tech
For logged in user the orders will be persisted in the database. what
i want is when a user logs out, a new anonymous profile will be
created, for this anonymous user the orders should be prepopulated.
below are the steps to be followed

1. Login
2. add some items (say item1) to cart
3. log out

Expected Result: for anonymous user item1 should be there in his cart

Actual result: whenever the user logs out shopping cart is getting
emptied out.


Note: whenever the user logs back to the site his items are persisted.
But the requirement is to persist cart when user logs out and a new
anonymous profile is created.

Naga

unread,
May 22, 2012, 9:34:59 AM5/22/12
to atg_...@googlegroups.com
Ok. I am not sure what we are discussing here, but it looks like you
misunderstood the concept of persisting orders for anonymous users.
You are asking this situation where in you want the items in your
logged in cart to be retained even after you purposefully logout which
I am not user is a real commerce scenario, please do validate and
confirm.

This isn't OOTB so you may have to handle it with custom logic
written with pre and postLogout users in ProfileFormHandler.

-Naga

Avinash

unread,
May 22, 2012, 9:45:56 AM5/22/12
to ATG_Tech
Yes Naga,
Exactly this is what i require. i want to retain the items in the cart
even after I purposefully logout.

I tried saving the order in preLogout and tried retrieving in
postLogout. but the issue i faced is in postLogout the profileId will
be same as the loggedin User's profileID. even all the properties of
logged in user is available in postlogout user method. getProfile()
will return the same logged in user's profile and not the new
anonymous profile. Below are the logs captured


Inside postLogout before super.postLogout
User status before postLogout: 4
User id before postLogout: 1992628
Order id before postLogout: 40008598
handleLogout: attempting to fire off Logout Event
handleLogout: session invalidated
User status after postLogout: 0
User id after postLogout: 1992628
Order id after postLogout: 40008598
Inside postLogout after super.postLogout


Here i am not able to get a new profile wherein i can copy the order
object.

Martain Chen

unread,
May 22, 2012, 10:33:09 AM5/22/12
to atg_...@googlegroups.com
Clone the order and write the order Id back in cookie, when anonymous user login, load that order for the user? Get new profile in login , even anonymous user will be logged in.

Send from my iPhone, please execute any typo.

Avinash

unread,
May 22, 2012, 11:56:39 AM5/22/12
to ATG_Tech
Hi Martain, Can you be little more specific. i did not get exactly
what you were suggesting



On May 22, 7:33 pm, Martain Chen <tododo.c...@gmail.com> wrote:
> Clone the order and write the order Id back in cookie, when anonymous user login, load that order for the user? Get new profile in login , even anonymous user will be logged in.
>
> Send from my iPhone, please execute any typo.
>

Martain Chen

unread,
May 22, 2012, 3:08:48 PM5/22/12
to atg_...@googlegroups.com
1. So ATG create an order for all users, even anonymous users. Now, you have the previous shopping cart persisted. You want ATG to load the order automatically, so you want to know the profile I'd that generated after logout. I am telling you that you can't know during logout. Best way is you clone the order, and write the I'd back to cookie. I am Suggesting customize in login. You will know the profile I'd at that time, and you only need to know the order I'd generated previously . I think when logout ATG will flush out all session scope objects. But session itself remains the same. Hence maybe write order I'd in the session attribute is also an option.

Send from my iPhone, please execute any typo.

Rob Sperandio

unread,
May 22, 2012, 3:42:17 PM5/22/12
to atg_...@googlegroups.com, atg_...@googlegroups.com
The cookie approach is how I do this. Override the createInitialOrder in OrderHolder and load an order based on the cookie's order id. You load up cookies in the profile pipeline and stuff them into the session.

There's no easy way to implement what you're trying to do, even though that's a very common functionality.

--
Rob
Reply all
Reply to author
Forward
0 new messages