Show cart info based on the logged in user
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 16
- Joined: 03 May 2016, 21:07
Show cart info based on the logged in user
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.
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
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
- https://github.com/aimeos/aimeos-core/b ... d.php#L907
- https://github.com/aimeos/aimeos-core/b ... d.php#L931
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 16
- Joined: 03 May 2016, 21:07
Re: Show cart info based on the logged in user
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
You can use something like this in the getSession*()/setSession*() methods:
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.
Code: Select all
$key = 'aimeos/basket/content-' . $sitecode . '-' . $language . '-' . $currency . '-' . strval( $type ) . '-' . $context->getUserId();
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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Show cart info based on the logged in user
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
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.