Store cart items for logged-in user

Help for integrating the Laravel package
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!
columbo
Advanced
Posts: 124
Joined: 09 Oct 2019, 09:42

Store cart items for logged-in user

Post by columbo » 10 Jun 2020, 12:02

Hi,

my Shop needs to log-in before you can add items to your cart. That works fine so far, but when a customer
  • adds items to his cart
  • does not checkout, but logos out
  • and logs in again -> his cart ist empty
How can I store the cart-items for a user, as long as he does not checkout or removes the items from his cart manually?

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

Re: Store cart items for logged-in user

Post by aimeos » 11 Jun 2020, 11:05

The cart is currently session based and you have to overwrite the get/setSession() method here to store it permanently for logged in users:
https://github.com/aimeos/aimeos-core/b ... e/Base.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

columbo
Advanced
Posts: 124
Joined: 09 Oct 2019, 09:42

Re: Store cart items for logged-in user

Post by columbo » 20 Jun 2020, 15:19

Thank you, but can you provide an additional hint please?
I have to store the logged in users basket in DB instead of session - correct?

Eg. for setSession() from https://github.com/aimeos/aimeos-core/b ... e/Base.php I have to replace:

Code: Select all

$session = $context->getSession();
...
$session->set( 'aimeos/basket/list', $list );
$session->set( $key, serialize( clone $order ) );
But how? Do I have to create a new table or add a new column to the laravel "users" table?
Does Laravel / Aimeos already provide any functionality for this?

columbo
Advanced
Posts: 124
Joined: 09 Oct 2019, 09:42

Re: Store cart items for logged-in user

Post by columbo » 26 Jun 2020, 10:37

any hint or tip how to solve this would be very great!
...Unfortunately, I have no clue how to proceed here

Post Reply