Skip to main content

Disable cart or cart memory

More
11 years 7 months ago #192653 by Jerome
Replied by Jerome on topic Disable cart or cart memory
Hi,

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.

More
11 years 7 months ago #192729 by FilipHradil
Hello,

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.

More
11 years 7 months ago #192750 by nicolas
Replied by nicolas on topic Disable cart or cart memory
Hi,

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.

More
11 years 7 months ago #192837 by FilipHradil
Hello,

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.

More
11 years 7 months ago #192862 by nicolas
Replied by nicolas on topic Disable cart or cart memory
Hi,

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.

More
11 years 7 months ago - 11 years 7 months ago #192993 by FilipHradil
Hello,

i tried it but it doesnt working.
See screens below.

Checkout -> adress NORMALLY



but when user complete his adress and click next and then he leave checkout without finishing order
there is this problem on steps with adress fields



Many thanks for help
Last edit: 11 years 7 months ago by FilipHradil.

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

More
11 years 7 months ago #193091 by nicolas
Replied by nicolas on topic Disable cart or cart memory
Are you sure that your users are logged in ?
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.

More
11 years 7 months ago #193168 by FilipHradil
Hello,

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:
Code:
..../checkout/updatecart

I have just another question to this topic.
My plugin, which reset car onBeforeCartUpdate
Code:
$cartClass->resetCart(); $cartClass = hikashop_get('class.cart'); $cartClass->resetCart(); $cartContent = $cartClass->get(); $cartClass->updateEntry($quantity,$cartContent,(int)$product_id,1,false,$type,$force);

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.

More
11 years 7 months ago #193190 by nicolas
Replied by nicolas on topic Disable cart or cart memory
Hi,

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.

More
11 years 7 months ago #193230 by FilipHradil
Hello,

sorry but I didn' work.

The condition works perfect if that case:
Code:
if(!is_array($cartClass->get()) || (!count($cartClass->get()))){ echo 'it works'; exit; }

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
Code:
if(!is_array($cartClass->get()) || (!count($cartClass->get()))) return;

Thank you

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

More
11 years 7 months ago #193275 by Jerome
Replied by Jerome on topic Disable cart or cart memory
Hi,

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.
The following user(s) said Thank You: FilipHradil

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

More
11 years 7 months ago - 11 years 7 months ago #193400 by FilipHradil
Hello,

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 :(
Last edit: 11 years 7 months ago by FilipHradil.

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

More
11 years 7 months ago #193401 by nicolas
Replied by nicolas on topic Disable cart or cart memory
Hi,

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.

More
11 years 7 months ago #193602 by FilipHradil
Hello,

I solved by no-programatically way.

Thank you

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

Time to create page: 0.215 seconds
Powered by Kunena Forum