Disable cart or cart memory

  • Posts: 26235
  • Thank you received: 4036
  • MODERATOR
10 years 2 months ago #192653

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #192729

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.

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #192750

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.

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #192837

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.

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #192862

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.

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #192993

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

Attachments:
Last edit: 10 years 2 months ago by FilipHradil.

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

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #193091

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.

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #193168

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:

..../checkout/updatecart

I have just another question to this topic.
My plugin, which reset car onBeforeCartUpdate
$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.

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #193190

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.

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #193230

Hello,

sorry but I didn' work.

The condition works perfect if that case:

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

Thank you

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

  • Posts: 26235
  • Thank you received: 4036
  • MODERATOR
10 years 2 months ago #193275

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: FilipHradil

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

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #193400

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: 10 years 2 months ago by FilipHradil.

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

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 2 months ago #193401

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.

  • Posts: 217
  • Thank you received: 4
10 years 2 months ago #193602

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.124 seconds
Powered by Kunena Forum