Multi Cart - Force new cart on login

  • Posts: 251
  • Thank you received: 21
2 months 1 week ago #361775

I have a situation where a company's employees access Joomla via the clients SAP integration. That means all that uses login via the SAP interface and it always uses the same username and login. This means that if two employees log in at the same time to place an order they end up sharing the same cart. My understanding is that with Multi Carts enabled, it is possible to have multiple carts simultaneously. My question is, can we force a new cart to be created at each login so the user is not changing a different employees cart? I should mention the SAP integration uses an auto login plugin that gets the username and password from url parameters passed to it so we can edit the events occurring at login in that code.

Please Log in or Create an account to join the conversation.

  • Posts: 82308
  • Thank you received: 13257
  • MODERATOR
2 months 1 week ago #361786

Hi,

With the multiple carts setting activated, a user can have several carts.
However, he only has one current cart. He can switch between his carts on his carts listing page.
The current cart is linked to the user entry and its cart_current is set to 1 while the other carts of the user are set to 0.
So, by default that means that all the browsers sharing the same user_id will see the same cart as the current cart.
If you want to allow different browsers logged in with the same user entry to have different current carts, it's technically possible, but it will require the development of a class override:
www.hikashop.com/support/documentation/6...ntation.html#classes
You want to override the file administrator/components/com_hikashop/classes/cart.php and in your override, you want to override the getCurrentCartId method. In it, you can pretty much do whatever you want so you could even return the id of the cart of someone else and it should allow HikaShop to load the cart from the other user as if it was the current user's cart.

Please Log in or Create an account to join the conversation.

  • Posts: 251
  • Thank you received: 21
2 months 1 week ago #361811

Hi Nicolas,
Thanks for that. I will have a look and see if this is within my capabilities.

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum