Page 1 of 1

Show cart info based on the logged in user

Posted: 10 May 2016, 22:59
by afoster009
Hello there, I am trying to set up aimeos so that each user is assigned their own cart.

Id like it so if i logged in with user A it would show their items they had in there cart, and if i log in with user B it will show the items they have in their cart.

As of now...When i log in with any user associated with my application the cart is the same for each user, containing the same items across all users.

Right now you must sign up to reach the /list page so you must be logged in to use the shop.

Im not sure how to configure aimeos to store unique cart info between users.

Re: Show cart info based on the logged in user

Posted: 11 May 2016, 06:40
by aimeos
The cart is bound to the session of the user. Each user has an own session, regardless which login he is using. If you want to enable the same user to have different sessions for each login, you have to overwrite the getSession()/setSession() method of the order base manager and add the user ID from the context:
- https://github.com/aimeos/aimeos-core/b ... d.php#L907
- https://github.com/aimeos/aimeos-core/b ... d.php#L931

Re: Show cart info based on the logged in user

Posted: 11 May 2016, 23:17
by afoster009
What exactly would the code look after i added the user ID into the context. Im by no means a professional programmer, so even an example would be fantastic

Re: Show cart info based on the logged in user

Posted: 12 May 2016, 00:56
by aimeos
You can use something like this in the getSession*()/setSession*() methods:

Code: Select all

$key = 'aimeos/basket/content-' . $sitecode . '-' . $language . '-' . $currency . '-' . strval( $type ) . '-' . $context->getUserId();
Extend the class, overwrite the named methods and configure the new class name for usage.
Also, be aware that this only works flawlessly for the requested context. If customer don't have to login first, the basket will be empty after they do so.

Re: Show cart info based on the logged in user

Posted: 25 Jul 2016, 10:31
by jossnaz
what aimeos is saying is that each user HAS his own cart. The thing you are doing is wrong, is for faking the customers, you use the same browser and no incognito mode. It is unlikely that users will use the same computer, with the same browser, to work with aimeos on different accounts, without logging out in between.

So for your testing case i guess it can work if you use a new incognito window for login
afoster009 wrote:Hello there, I am trying to set up aimeos so that each user is assigned their own cart.

Id like it so if i logged in with user A it would show their items they had in there cart, and if i log in with user B it will show the items they have in their cart.

As of now...When i log in with any user associated with my application the cart is the same for each user, containing the same items across all users.

Right now you must sign up to reach the /list page so you must be logged in to use the shop.

Im not sure how to configure aimeos to store unique cart info between users.