- Posts: 113
- Thank you received: 18
Multi Carts don't work from front-end
The wishlists feature suffers from the same flaw. It works if you create new cart / wishlist from the back-end, but customers can't create more than one wishlist or cart.
Please Log in or Create an account to join the conversation.
In the file: "yourSite\administrator\component\com_hikashop\classes\cart.php" in the function "loadCart()" is the code:
Please Log in or Create an account to join the conversation.
The described functionality doesn't work on your demo site either.
Please Log in or Create an account to join the conversation.
I tried on my end and this functionality is working fine, the correction will be in the next release which will arrive before the end of the month.
Please Log in or Create an account to join the conversation.
I can confirm that this isn't working on your demo page, either. (at least for Google Chrome 22.0.1229.79 - Windows 7)
In addition, this if statement you referred to:
does not even exist in my version (Business 1.6.0)Xavier wrote:
Code:if($app->getUserState(HIKASHOP_COMPONENT.'.'.$this->cart_type.'_new', '0') == '0'){
Please Log in or Create an account to join the conversation.
You can try the beta already here:
www.hikashop.com/en/forum/2-general-talk...ikashop-20-beta.html
The demo website doesn't have yet HikaShop 2.0 since it is still a beta, so it's normal that it doesn't work there.
Please Log in or Create an account to join the conversation.
Thanks for your reply, I'm looking forward to Ver2!
Please Log in or Create an account to join the conversation.
I needed this working by tomorrow as it was presented to my client in a previous version ( we upgraded last week )
After some hour of testing, I did the following:
1. Add the given code line to the loadCart() method of the cart class: (and the closing bracket)
2. Around line 74 of the cart controller, I changed:
From:
To:
This makes the userstate var be 1 until something else resets it to 0. This causes the loadCart() method to not load any cart.
3. In the same Cart controller file, in the addtocart() method, around line 130, there is a line for resetting the userState var to 0, but it is set after the class is instanced, so the class creates another new cart.
The only way to make it stop was by moving line 136 to line 118, to set the userState before the new call to the cart class. (line numbers may vary)
Like this-> screencast.com/t/JrgUlMNb3
It seems to be working for me with those mods. -> screencast.com/t/M5EuQ7Pp6
The only remaining broken thing is that it should mark the current cart as active...
Eduardo Chongkan - Likan Development
likandevelopment.com
Please Log in or Create an account to join the conversation.
Firstly, I got an error when trying to access "Show the carts" from the customer account page:
Fatal error: Call to a member function get() on a non-object in /var/www/components/com_hikashop/views/cart/view.html.php on line 248 (and 49 respectively)
I resolved this by commenting out the according lines in the view, since I don't intend to use wishlists anyway. Otherwise, this would probably pose another problem.
Secondly, HikaShop doesn't seem to load the current cart after user login. This might actually be a feature rather than a bug - maybe you don't want this stuff back anyway. However, I need to rely on the loaded cart having the same contents as the cart marked current in the MySQL table to manipulate these contents with ajax requests. I managed to write a module, that does this loading on login for me, but I fear that this will run into other problems sooner or later...1)
TL;DR: This script loads the last modified cart, makes it current and redirects to the index.php of your page
| 1) | And it already did: This won't work, of course, if you log in through any "You must log in first" page rather than the original login page2) |
| 2) | Managed to get around that as well - by hacking the Joomla core though. I made the /components/com_user/controller.php redirect eeevery login to my module and pass the actual redirection url as a GET argument (base64 encoded). I added the ensuing decoding and redirecting to the code above. |
Please Log in or Create an account to join the conversation.
Eduardo Chongkan - Likan Development
likandevelopment.com
Please Log in or Create an account to join the conversation.
Exactly - and I'm running into further problems with that.likandev wrote: I also noticed that carts are not marked as active in the showcarts view.
Even though the most recently edited cart is now marked as current on login, you can still just delete the current cart and no cart will be marked current again. If you can just tell me where HikaShop decides which of the remaining carts to load (but not mark current), I could adjust that in my source code.
EDIT: Forgot to mention that I also seem to be unable to clear the cart from the HikaShop cart module ( X linking to index.php?option=com_hikashop&ctrl=product&task=cleancart&Itemid=...)
Please Log in or Create an account to join the conversation.
For my product/listing_table view I used to look up the current cart in the MySQL database to display the respective quantities from the cart next to each product. Since the actually loaded carts on the front end sometimes don't (or better: hardly ever) correlate to the carts marked current in the MySQL table, this would not work anymore.
By digging around in the HikaShop source, I found out that I could use
This does, however, neither solve the issue
- that the current cart and the actually loaded cart may not be the same,
- that, on login, a new (empty) cart is created instead of the last one being loaded (I'm still relying on my module from above),
- nor that I'm still unable to clear a cart from the cart module (Which might be a good thing depending on your perspective - in that case, however, the clear (X) button shouldn't be displayed in the first place)
Please Log in or Create an account to join the conversation.
Why don't you just put a cookie with the user's last cart ID and get the ID from there after login?
By using the cart helper class they put as an example in the documentation?
Eduardo Chongkan - Likan Development
likandevelopment.com
Please Log in or Create an account to join the conversation.
Eduardo Chongkan - Likan Development
likandevelopment.com
Please Log in or Create an account to join the conversation.
That's why, on user login, I look up the last edited cart and set it as current. That way, HikaShop loads it.likandev wrote: Carts are also associated to session IDs. Also, if you are logging in, and if Hikashop doesn't auto load the cart, you shouldn't expect to find the correct cart ID in the session var.
If I did that and the user deleted the currently loaded cart, another cart would be loaded by HikaShop rendering my cookie obsolete.Why don't you just put a cookie with the user's last cart ID and get the ID from there after login?
I found this in /components/com_hikashop/controllers/cart.phpBy using the cart helper class they put as an example in the documentation?
Please Log in or Create an account to join the conversation.