How to manage customer basket

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
PaoloLegaspi
Posts: 24
Joined: 07 Nov 2024, 15:02

How to manage customer basket

Post by PaoloLegaspi » 19 Nov 2024, 05:56

Hi,
I’m working with Aimeos Headless and JWT, and I’ve run into an issue with user basket items. Since the customer basket is tied to the session, I was wondering if it’s possible to handle these scenarios:

1. Merge or restore a guest basket with the user’s existing basket when they log in.
2. Persist customer’s basket even after they log out or when the session ends.

Any guidance on this would be much appreciated!

Thanks!

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: How to manage customer basket

Post by aimeos » 22 Nov 2024, 09:05

It's possible when you extend the Laravel/JWT login controller to load the last basket of the customer. The basket is already stored in the database with the ID of the customer if he is logged in.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
PaoloLegaspi
Posts: 24
Joined: 07 Nov 2024, 15:02

Re: How to manage customer basket

Post by PaoloLegaspi » 09 Dec 2024, 11:57

Hi,
I noticed an issue where, if a client adds products to their basket before logging in, those items don’t carry over after they log in. The basket also doesn’t get linked to the customer’s account. How can I make sure the basket items persist after the user logs in?

Code: Select all

Aimeos version: Aimeos Headless 2024.07.*
PHP version: 8.2
Environment: Mac

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: How to manage customer basket

Post by aimeos » 13 Dec 2024, 12:04

The basket is session based, so make sure you send the correct (same) session cookie value to the server after login. The basket is stored in the database using a "token", which is stored in that session:
https://github.com/aimeos/aimeos-larave ... #L260-L267
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: How to manage customer basket

Post by aimeos » 13 Dec 2024, 12:16

Regarding the customer ID which isn't added to the basket after login, please update aimeos/ai-controller-frontend to 2024.10.x-dev. This change should improve the situation to assign the customer ID to the basket when customers log in after the basket has been created:
https://github.com/aimeos/ai-controller ... 97eb636048
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
PaoloLegaspi
Posts: 24
Joined: 07 Nov 2024, 15:02

Re: How to manage customer basket

Post by PaoloLegaspi » 16 Dec 2024, 02:57

Hello, I just updated to the new version, and it’s now working on our end. Thank you! :D

Post Reply