1

I am using Drupal Commerce for a portal & I am facing a issue which is re-producible on fresh instance as well.

Suppose if I have a account on a website and I am logged in. I add some items to my cart and leave. It will remain in my cart even if I login from another system.

But if I don't login from another system at start & click "Add to Cart", item get added to my cart with help of session. Now if I login into system, only current items are in cart, not which I have added from another system in my account.

I mean, we loose those items which were in cart before.

This behaviour I checked on some other ecommerce website as well, but they add session cart into the account cart once you login.

What can be the solution of this ?

2 Answers 2

1

What you describe is the default behavior in Drupal Commerce, as it is supporting the idea of "multiple carts", so when you log in you get the items that you've got in your current cart and the other cart will be kept in the "background".

In fact, if you end the purchase you have once logged in, you'll most probably see that the items you had in the cart in the first place are back in there.

I'm afraid this is something you can't solve without some coding or rules, the theory here is that on the user login event, you get all the past orders from that user and combine them in the current cart of the user. This is not something you normally want as the cart pulled might be old.

2
  • Yes you are right. I found this after I asked this question. But I am still struggling in a condition where user reach to checkout for current cart but don't go forward, then he loose old cart :(
    – RajeevK
    Commented Dec 2, 2013 at 6:12
  • 1
    For reference, see this duplicate issue in the Commerce queue: drupal.org/node/2145173 Rajeev, please only post a support request in one location next time. Now we have duplicate content in a closed issue that will never help anyone else. :-/ Commented Dec 2, 2013 at 19:18
0

According to me the best solution would be to automatically logout or close the session after pre-defined period of time. For that the 2 modules which can be used are as follows:

Session Limit

Session Limit allows administrators to limit the number of simultaneous sessions per user.

Max session is configurable, no database tables needed.

By default, a session is created for each browser that a user uses to log in. This module will force the user to log out any extra sessions after they exceed the administrator-defined maximum.

Assuming the session limit is 1, if a user is logged in to a Drupal site from their work computer and they log in from their home computer, they would be forced to either log off the work computer session, or abort their new login from home.

Automated logout

This module provides a site administrator the ability to log users out after a specified time of inactivity. It is highly customizable and includes "site policies" by role to enforce logout.

Features Different timeouts based on role Disabling of timeouts based on role Permission for users to set their own timeout Includes some JS mechanisms to keep uses logged in even if multiple tabs are open or if the user is working on a form for a long period of time. Includes developer hooks to allow users to remain logged in depending on your own project specific requirements Optional integration with Javascript Timer

3
  • 1
    Thanks for taking your time & responding. But this can't solve the issue as it's not the session issue. Even if I log out from current session & start adding items in cart at another system, I loose the previous cart items once I log in.
    – RajeevK
    Commented Nov 27, 2013 at 10:46
  • maybe u may require some combination of user and session to solve the issue
    – harshal
    Commented Nov 27, 2013 at 10:53
  • I think it's not related to current session but the old items in cart :)
    – RajeevK
    Commented Nov 27, 2013 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.