Disable cart or cart memory
The login/logout is related to Joomla itself.
For this kind of question, I am recommending your the Joomla documentation and the Joomla forum.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
thank you.
I have checkout just for guests and when user complete his adress and email he is "logged in" and when he left the order without completing he is still logged.
I need to logg him out
Thank you
Please Log in or Create an account to join the conversation.
He will be logged out automatically when his user session expire. It depends what you configured in the "session lifetime" option of the joomla configuration.
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
thank you, but I need to loggout user immediately when updating cart, becasue when he left order and order something again he can't change his adress fields.
Thanks
Please Log in or Create an account to join the conversation.
So why not let them handle their login/logout themselves with the joomla login module ?
Logout can be done like that with Joomla:
$app = JFactory::getApplication();
$app->logout();
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
Please Log in or Create an account to join the conversation.
It looks like you're using the guest mode and in that case, there is no loging and thus no logout.
What to want to do in that case is just reset the user session with such code:
$app = JFactory::getApplication();
$app->setUserSate('com_hikashop.user_id', null);
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
thank you for your willingness
Despite it looks it should work it doesn't. When I putted your code to my plugin's function it redirected me to blank page with link:
I have just another question to this topic.
My plugin, which reset car onBeforeCartUpdate
If I have expired cookies and I would add product it prints error message: The cart is empty.
In second try it works but just until cookies expired.
Is there any condition which check if is cookies for cart exists?
Good bless you
Filip
Please Log in or Create an account to join the conversation.
1. I don't see why that code would generate a blank page.
2. Sure. You can add such check:
if(!is_array($cartContent) || !count($cartContent) ) return;
that way, if no products are already in the cart, the code after that won't be executed.
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
sorry but I didn' work.
The condition works perfect if that case:
But with return it causes same thing. Redirect to product listing with notification: The cart is empty
I suppose it causing getting content of cart
Thank you
Please Log in or Create an account to join the conversation.
Nicolas gave you some working code but not for your specific code context.
So the condition is working fine in every cases ; After that, it's up to you to modify what after the if to perform what you want to do.
Please understand that you are in the trigger "onBeforeCartUpdate" and that trigger have parameters and some other stuff to control the update of the cart.
I recommend you to check the trigger details in the developer documentation.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
thank you, I thought it but I don't know php, but with Nicolas's help we made almost working plugin.
Last thing what I need is to check if session exists for cart.
I can't do it by myself. I spent hours about it
Please Log in or Create an account to join the conversation.
You can look into the $_COOKIES variable. There, you have all the cookies stored.
There is however no cookie for the cart in HikaShop.
HikaShop stored the id of the current cart in the user session and you can get it like that:
$app = JFactory::getApplication();
$cart_id = $app->getUserSate('com_hikashop.cart_id');
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
- Posts: 217
- Thank you received: 4
I solved by no-programatically way.
Thank you
Please Log in or Create an account to join the conversation.