How to Get the User’s Basket ID from the Session
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- Paulus-Ragnarr
- Posts: 25
- Joined: 15 Oct 2024, 07:02
How to Get the User’s Basket ID from the Session
Hi,
I’m trying to figure out how to get the user’s current basket ID from the session. Here’s the scenario:
We have a checkout process where a guest can log in(after products are added), and we noticed that the customerid is only set in the basket order object but doesn’t get saved to the database in this case. We want to handle a situation where the user doesn’t complete the checkout and logs out of the shop. In that case, we’d like to save the customerid (if it doesn’t already exist) to the database before they log out. This way, if the user logs in again later, their previous order data will still be available.
Right now, I’m using this query to fetch the user’s basket data:
ENV
I’m trying to figure out how to get the user’s current basket ID from the session. Here’s the scenario:
We have a checkout process where a guest can log in(after products are added), and we noticed that the customerid is only set in the basket order object but doesn’t get saved to the database in this case. We want to handle a situation where the user doesn’t complete the checkout and logs out of the shop. In that case, we’d like to save the customerid (if it doesn’t already exist) to the database before they log out. This way, if the user logs in again later, their previous order data will still be available.
Right now, I’m using this query to fetch the user’s basket data:
Code: Select all
$basket = \Aimeos\MShop::create($this->getSessionContext(), 'order')->getSession();
Code: Select all
Aimeos version: Aimeos Headless 2024.10.*
PHP version: 8.2
Re: How to Get the User’s Basket ID from the Session
It would be better to retrieve the current basket of the user during login, set the user ID and save the basket again instead of doing this on logout because users can also leave the site without logging out.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
