[Skip to main content](#vessel-content)

#   Shopping Cart Based on Browser Session

##

- **[11Studios](/forum/user/37269-11studios "View 11Studios's Profile")**
- [![11Studios's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37269-11studios "View 11Studios's Profile") Topic Author
- [ Offline](/forum/user/37269-11studios)

Less More

- Posts: 9
- Thank you received: 0
-
-

11 years 5 months ago -  11 years 5 months ago [\#204398](#204398) by [11Studios](/forum/user/37269-11studios "View 11Studios's Profile")  *[Shopping Cart Based on Browser Session](/forum/27-checkout/877451-shopping-cart-based-on-browser-session#204398 "-- HikaShop version -- : 1504301217 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.6 -- Browser(s) name and version -- : All  I have multiple clients using the same user / pass for a fundraiser. It's easier to assign one user/pass to the organization to give out to 100 users vs creating 100 accounts. The purpose is to collect all the orders under one user/pass as well as the ability to show/hide specific Joomla menu items based on which organization logs in.  My problem is when I make them a registered user, the Hikacart automatically saves the cart in the database and everyone logged in can see it. For now, I have set the menu item to public so they can shop as a guest and log in at the very end, clearing the cart on purchase. It's a work around, but it prevents us from using the access levels in Joomla and if they click &quot; continue shopping&quot; at the end, then the cart is saved and the problem arises again. I've tried almost every option and I can't figure out a solution.  Is there a way around this, or do you have any suggestions?")* was created by *[11Studios](/forum/user/37269-11studios "View 11Studios's Profile")*

-- HikaShop version -- : 1504301217
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.6
-- Browser(s) name and version -- : All

I have multiple clients using the same user / pass for a fundraiser. It's easier to assign one user/pass to the organization to give out to 100 users vs creating 100 accounts. The purpose is to collect all the orders under one user/pass as well as the ability to show/hide specific Joomla menu items based on which organization logs in.

My problem is when I make them a registered user, the Hikacart automatically saves the cart in the database and everyone logged in can see it. For now, I have set the menu item to public so they can shop as a guest and log in at the very end, clearing the cart on purchase. It's a work around, but it prevents us from using the access levels in Joomla and if they click " continue shopping" at the end, then the cart is saved and the problem arises again. I've tried almost every option and I can't figure out a solution.

Is there a way around this, or do you have any suggestions?

Last edit: 11 years 5 months ago by [11Studios](/forum/user/37269-11studios "View 11Studios's Profile"). Reason: rewording information

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzQ1MS1zaG9wcGluZy1jYXJ0LWJhc2VkLW9uLWJyb3dzZXItc2Vzc2lvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

11 years 5 months ago [\#204412](#204412) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Shopping Cart Based on Browser Session](/forum/27-checkout/877451-shopping-cart-based-on-browser-session#204412 "-- HikaShop version -- : 1504301217 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.6 -- Browser(s) name and version -- : All  I have multiple clients using the same user / pass for a fundraiser. It's easier to assign one user/pass to the organization to give out to 100 users vs creating 100 accounts. The purpose is to collect all the orders under one user/pass as well as the ability to show/hide specific Joomla menu items based on which organization logs in.  My problem is when I make them a registered user, the Hikacart automatically saves the cart in the database and everyone logged in can see it. For now, I have set the menu item to public so they can shop as a guest and log in at the very end, clearing the cart on purchase. It's a work around, but it prevents us from using the access levels in Joomla and if they click &quot; continue shopping&quot; at the end, then the cart is saved and the problem arises again. I've tried almost every option and I can't figure out a solution.  Is there a way around this, or do you have any suggestions?")*

Hi,

The cart is based on the session when the user is not logged.
That information is also used for the logged user to retrieve their cart when they were not logged yet.
But when a user is logged, he has just one "current cart" and it will be difficult to change that except by modifying some HikaShop core files.
Maybe using a special "sort" in order to get the cart linked to the current session before the cart linked to the user.
But when the user will finish his order, he will retrieve another cart.. And when a user will log-in with any cart in session he will retrieve an existing cart... So it will be really really hard to say.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzQ1MS1zaG9wcGluZy1jYXJ0LWJhc2VkLW9uLWJyb3dzZXItc2Vzc2lvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[11Studios](/forum/user/37269-11studios "View 11Studios's Profile")**
- [![11Studios's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37269-11studios "View 11Studios's Profile") Topic Author
- [ Offline](/forum/user/37269-11studios)

Less More

- Posts: 9
- Thank you received: 0
-
-

11 years 5 months ago [\#205099](#205099) by [11Studios](/forum/user/37269-11studios "View 11Studios's Profile")  Replied by *[11Studios](/forum/user/37269-11studios "View 11Studios's Profile")* on topic *[Shopping Cart Based on Browser Session](/forum/27-checkout/877451-shopping-cart-based-on-browser-session#205099 "-- HikaShop version -- : 1504301217 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.6 -- Browser(s) name and version -- : All  I have multiple clients using the same user / pass for a fundraiser. It's easier to assign one user/pass to the organization to give out to 100 users vs creating 100 accounts. The purpose is to collect all the orders under one user/pass as well as the ability to show/hide specific Joomla menu items based on which organization logs in.  My problem is when I make them a registered user, the Hikacart automatically saves the cart in the database and everyone logged in can see it. For now, I have set the menu item to public so they can shop as a guest and log in at the very end, clearing the cart on purchase. It's a work around, but it prevents us from using the access levels in Joomla and if they click &quot; continue shopping&quot; at the end, then the cart is saved and the problem arises again. I've tried almost every option and I can't figure out a solution.  Is there a way around this, or do you have any suggestions?")*

Thank you for your response. It would be great to have this ability in future releases. I don't mind creating overrides for Hikashop, I've looked into some of the core files. I'm beginner / intermediate in PHP so some of the code was a little over my head. When you say edit the core, you are referencing I could test trying the following? Which file would I look in to start?

"Maybe using a special "sort" in order to get the cart linked to the current session before the cart linked to the user."

Right now, I have the cart prompt for user login when they go to pay. ( last step ).I wonder if I could edit the core to automatically submit the order and immediately log them out to a thank you page when they click "login". This way it clears the cart, logs them out preventing them from creating a new cart, thus solving the multiple cart issue for now. I can figure out another way to show / hide the links using a custom login separate from Joomla once I solve this.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzQ1MS1zaG9wcGluZy1jYXJ0LWJhc2VkLW9uLWJyb3dzZXItc2Vzc2lvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

11 years 5 months ago [\#205144](#205144) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Shopping Cart Based on Browser Session](/forum/27-checkout/877451-shopping-cart-based-on-browser-session#205144 "-- HikaShop version -- : 1504301217 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.6 -- Browser(s) name and version -- : All  I have multiple clients using the same user / pass for a fundraiser. It's easier to assign one user/pass to the organization to give out to 100 users vs creating 100 accounts. The purpose is to collect all the orders under one user/pass as well as the ability to show/hide specific Joomla menu items based on which organization logs in.  My problem is when I make them a registered user, the Hikacart automatically saves the cart in the database and everyone logged in can see it. For now, I have set the menu item to public so they can shop as a guest and log in at the very end, clearing the cart on purchase. It's a work around, but it prevents us from using the access levels in Joomla and if they click &quot; continue shopping&quot; at the end, then the cart is saved and the problem arises again. I've tried almost every option and I can't figure out a solution.  Is there a way around this, or do you have any suggestions?")*

What I would recommend is to modify the function restoreSession in the file plugins/system/hikashopuser/hikashopuser.php
This function is called when the user logs on the website.
You can see at the beginning some the code loading the cart from the anonymous session (before the login).
So you want to keep that.
What you can do is after that, is to check if you have something in $app-&gt;getUserState('com_hikashop.cart_id')
If not, it means that the user didn't already had a cart and you can run a query to remove all the carts of the user in the hikashop_cart and hikashop_cart_user tables.
If yes, it means that the user had a cart before logging in, and you can run a query to remove all the carts of the user in the hikashop_cart and hikashop_cart_user tables expect the one with the cart_id from the user state.

That shouldn't be too complex. The problem with this method, is that if you have two persons using the same account at the same time, they could delete one another's cart.

What Jerome suggests is better but way more complex to do. You basically need to modify the file administrator/components/com_hikashop/classes/cart.php in different places. It's not an easy thing and you risk breaking the system.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzQ1MS1zaG9wcGluZy1jYXJ0LWJhc2VkLW9uLWJyb3dzZXItc2Vzc2lvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.061 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
